Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Do not load state=new translations #507

Open
goetas opened this issue Jan 30, 2019 · 0 comments
Open

[RFC] Do not load state=new translations #507

goetas opened this issue Jan 30, 2019 · 0 comments

Comments

@goetas
Copy link
Collaborator

goetas commented Jan 30, 2019

Q A
Bundle version master
Symfony version 3.4
PHP version 7.2

This is not a bug issue.

Is more of a RFC.

Currently Translation/Loader/Symfony/XliffLoader.php loads all the translations in the symfony catalogue.

Does it make sense to skip translations marked as new ?

The reason for this is that new strings are in 99% of cases not translated. Currently the loader considers them as translated and does not fallback on the default locale setting.

In my case i have:

PHP:

echo $translator->trans('welcome_message');

I extract the translations using the extract command (extracted for en and es language). This generates:

messages.en.xlf

<trans-unit id="123" resname="welcome_message">
  <source>welcome_message</source>
  <target state="new">welcome_message</target>
</trans-unit>

messages.es.xlf

<trans-unit id="123" resname="welcome_message">
  <source>welcome_message</source>
  <target state="new">welcome_message</target>
</trans-unit>

A as first thing I translate messages.en.xlf.
welcome_message is translated as Hi!.

messages.en.xlf

<trans-unit id="123" resname="welcome_message">
  <source>welcome_message</source>
  <target>Hi!</target>
</trans-unit>

When a user has es locale:

$translator->setLocale('es');
echo $translator->trans('welcome_message'); // prints welcome_message

prints welcome_message instead of Hi!.

This is because <target state="new">welcome_message</target> is considered as translated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant