Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Suggestion on the translation system #40418

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

Closed
ghost opened this issue Mar 8, 2021 · 6 comments
Closed

Suggestion on the translation system #40418

ghost opened this issue Mar 8, 2021 · 6 comments

Comments

@ghost
Copy link

ghost commented Mar 8, 2021

Description
Symfony allows you to do a lot of things, but I'm having a hard time managing languages. We do not exploit the potential of language files.
The Xliff, for example, you cannot put comments in the code, it is ignored, and if you put the comments in an xlif file, during the next update run, they are all deleted. Identical for po files. I read your files and watch to keep it simple, because there is no point in making gas plants either. I therefore took over the basis of the management of po files to directly manufacture templates, .pot.

We make the best use of the generated files and the use of PoEdit or others to translate the files with the keys and the source text. Then we take the translation program we open the .pot file, we translate, we save it in .po, the little tinkering I change the extension to .to so as not to modify the existing po system. Which gives as in the examples.

Example

By default

msgid "validator.empty.value"
msgstr "__validator.empty.value"

Capture d’écran du 2021-03-08 19-12-06

With feature

#. S "validator.selection.choice"
msgctxt "Conseille"
msgid "Cette valeur doit être l'un des choix proposés."
msgstr "Cette valeur doit être l'un des choix proposés."

#. S "validator.select.choice"
#. P "validator.select.choices"
msgctxt "Conseille 2"
msgid "You must select at least {{ limit }} choice."
msgid_plural "You must select at least {{ limit }} choices."
msgstr[0] "Vous devez sélectionner au moins {{ limit }} choix."
msgstr[1] "Vous devez sélectionner au moins {{ limit }} choix."

#. S or P using comment developper for key
msgctxt for context eg : Rage, Important, Happy etc..
and msgid they are really used for text

Look bottom right
For single
Capture d’écran du 2021-03-08 19-12-22

For plurial
Capture d’écran du 2021-03-08 19-12-30

I will not hide from you that this is the first time that I use a framework and I chose Symfony to create a project (self-taught) and to do well this project is a game that integrates forum, blog, chat, discord link etc. If I cut it represents 47 bundles. Given its size and complexity, I find myself faced with things that are missing. May I also suggest, would it be possible to add a setDefaultdomain to TranslatorInterface to avoid putting each time the domain for which the translation is intended in the controllers?

Here are the files necessarily you have to do the service in the configurations.
Translator.tar.gz

Thank you :)
Regards,

@Nyholm
Copy link
Member

Nyholm commented Mar 9, 2021

Hey.

Cool. It looks like you want to modify the PoFileDumper and PoFileLoader. I've done something similar to the XLIF format.

Slightly related: This PR might be interesting for you: #38475. It creates a connection with the online PoEdit so you can import/export translation files to your project.

About TranslatorInterface::setDefaultDomain(), that method would force the service to hold state, that is never good. I suggest you implement a new class that decorates a TranslatorInterface. That way you can easily modify the default domain.

@liarco
Copy link
Contributor

liarco commented Mar 9, 2021

Hi, nice to see an effort put into improving translators/devs experience with i18n.

I never used po files with Symfony, but I recently moved from yaml to xliff to take advantage of the notes feature to store useful metadata: https://symfony.com/doc/current/translation/xliff.html

I also opened a PR that implements translation variables extraction as additional notes: #38884 (there's a screenshot that shows PoEdit support to XLIFF notes)

@ghost
Copy link
Author

ghost commented Mar 9, 2021

Hi,

@Nyholm
Yes, the translation, the text is for me something important when developing an application, from my point of view anyway. I am really surprised that we do not think to facilitate the translation. My project is private but it will be playable for free, to help me with the translations, I have to think about allowing as many people as possible to translate easily, not everyone is a developer, they do not know how to have a hand in the raw code. Poedit also does the Xliff altogether, at the beginning I used this format, but looking more closely at the possibilities of the PO file and its POT template. I tell myself that there is a way to do a great thing, simple to build as a developer and pleasant to translate for contributors.

For the setDefaultDomain, it is to have the same operation as under Twig with {% trans_default_domain 'mynamefile' %}. I take note of your remark anyway.

@liarco
Yes it is practically the same thing. Knowing that there are the notes for the translators of which I have put the key but we can also add comments. By putting this in templates, which serve as the source to design all languages. Anyway ... It's a suggestion worth considering.

For the code, I did something fast based on the translation codes, as I don't know Symfony too much, I'm going gradually XD

Regards,

@carsonbot
Copy link

Thank you for this issue.
There has not been a lot of activity here for a while. Has this been resolved?

@carsonbot
Copy link

Could I get a reply or should I close this?

@carsonbot
Copy link

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

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

No branches or pull requests

4 participants