GithubHelp home page GithubHelp logo

Comments (4)

henry-torproject avatar henry-torproject commented on June 8, 2024 1

This escaping is intentional in the translate-toolkit code, see https://github.com/translate/translate/blob/bf3b519010fd6c0f3cd53b210b5e1eb6be33bd8c/translate/storage/fluent.py#L55-L88.

If you feel this behavior should be changed, please open up an issue there.

@henry-torproject might be interested in this as well as an author of the referenced code.

Yes, it is indeed intentional.

The first thing to note is that { "[" } is a Fluent string literal, so

hud-init-stage-client-load-init-data = { "[" }{ -client }]: Loading

will produce exactly the same string as

hud-init-stage-client-load-init-data = [{ -client }]: Loading

so there should be no change in the end result.

The "[" at the start of a line is reserved in Fluent for selectors. E.g.

my-fluent-string = { $num ->
  [one] { $num } item
 *[other] { $num } items
 }

In your example, the original source is:

my-fluent-string = [ other

Since the "[" does not appear at the start of a line, it is technically valid. But the following are not:

my-fluent-string =
  [ other
my-fluent-string = first line
  [ second line
my-fluent-string =
  first line
  [ second line

On weblate, the user does not see the my-fluent-string line, and only sees everything after the "=" sign. You can think of the weblate input as everything that occurs after the "=" sign minus the indent. So

first line

second line

in the weblate input would become

my-fluent-string =
  first line
  second line

and simialrly

> [ other

would become

my-fluent-string =
  [ other

which is invalid Fluent.

Whilst we could have allowed for exceptions for the special case, it would have appeared inconsistent in the weblate context.

Besides the fact that [ gets replaced with { "[" } in Weblate, after you translate this problematic string, you receive the following error (but it still saves the translation):

Fluent translation syntax
Fluent syntax error: E0005: Expected message "hud-init-stage-client-load-init-data" to have a value or attributes [line 1, column 1].

This is because you need to escape the special "[" character, as in the original string. It would need to be

{ "[" }{ -client }]: Cargando

instead.

In this case, you may prefer to explicitly use

{ "[" }{ -client }{ "]" }: Loading

to make the string more symmetric, even though it is not necessary.

from weblate.

nijel avatar nijel commented on June 8, 2024

This escaping is intentional in the translate-toolkit code, see https://github.com/translate/translate/blob/bf3b519010fd6c0f3cd53b210b5e1eb6be33bd8c/translate/storage/fluent.py#L55-L88.

If you feel this behavior should be changed, please open up an issue there.

@henry-torproject might be interested in this as well as an author of the referenced code.

from weblate.

github-actions avatar github-actions commented on June 8, 2024

The issue you've reported needs to be addressed in the translate-toolkit. Please file the issue there, and include links to any relevant specifications about the formats (if applicable).

from weblate.

walpox avatar walpox commented on June 8, 2024

Thank you for the clarification.

from weblate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.