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

Translation issue or translation feature request #1561

Closed
nja78 opened this issue Jul 24, 2015 · 6 comments
Closed

Translation issue or translation feature request #1561

nja78 opened this issue Jul 24, 2015 · 6 comments

Comments

@nja78
Copy link

nja78 commented Jul 24, 2015

Translation function does not use necessary phrase translation from dictionary or it is not possible to translate the same phrase differently in different modules.

I try to translate Magento2 to Russian language. Have issue with some phrase translations. For example:
Name => Имя (Meant: Your Name or First Name + Last Name or User Name. ) (used in Contact Us form or on many forms from 3rd party developers)
Name => Название (Meant: Product Name, Store Name, Group Name etc. - inanimate) (used in Product edit form, Store edit form etc)

Of course i can modify core files or theme templates, but i do not think that it is good idea. Language pack should not modify any core files or templates.
To provide my language pack i cannot use "Translate Inline" to translate such phrases.

But i think there is problem with translation function. Dictionary contains information about extension or theme where this phrase is used.
I have tried to separate phrase to two lines for different modules, but no luck.

@Vinai
Copy link
Contributor

Vinai commented Jul 24, 2015

This is one feature Magento 1 provided, but as far as I know it was dropped for Magento 2.
Maybe it can be set up for grabs for community PRs, as I also found the ability for strings to be translated differently on a module basis useful sometimes.
I might be wrong though - maybe someone from the core team can explain and let us know if this maybe even already possible, or is on the roadmap or not.

@ghost
Copy link

ghost commented Jul 25, 2015

See if this helps: http://devdocs.magento.com/guides/v2.0/architecture/behavior/xlate.html, "Module and theme [language] packages. Included in the i18n directory of a module or theme, the Magento application auto-discovers these packages."

http://devdocs.magento.com/guides/v2.0/architecture/behavior/xlate.html#m2devgde-xlate-languagepack

@nja78
Copy link
Author

nja78 commented Jul 27, 2015

Thank you for your interest in my post. I have read this documentations more than once.
But it does not help me in finding the solution that will help one and the same phrase translated in different ways for different modules.

I haven't digged the code very deeply, but what I see is not encouraging. I just hope that I've missed something.
Function loadData in file /lib/internal/Magento/Framework/Translate.php returns an array with phrases that are used by Magento for translating.
Phrases are loaded from all modules and themes, but in the result array we can see only one row per phrase. If I translate phrase Name in each extension differently, I get only one translation, that is loaded last. And I cannot influence the way to choose what translation on what page or template to use.

Let's look at the same example with the phrase "Name", excluding the impact of theme translation and let's look only at translation of the phrase in the admin.

  1. System -> Integrations
    First field in the grid - Name. We translate it as Название.
    Add phrase translation to file /app/code/Magento/Integration/i18n/ru_RU.csv

Checking. Translation is ok.

  1. Customers -> All Customers
    3rd field in grid - Name. We will translate it as Имя.
    But at this moment translation already is Название - translation from extension Integrations.
    Add new translation to file /app/code/Magento/Customers/i18n/ru_RU.csv

Nothing changed. Old translation used.
Removing phrase from extension Integrations translation file - now I see translation from extension Customers in both grids.

I need to know: have I missed something or it works as intended? How to translate phrase differently for different contexts?
Should I start to think how to improve this mechanism, or there are plans to change it and I should wait with translations for Magento2?

@TpyMaH
Copy link

TpyMaH commented Aug 13, 2015

Alternatively, you can give an ability to make translations namespace specific.
For example there is a global phrase "Hello", "Привет"
At the same time this phrase is in the namespaces:
mage/customer - "Hello":"Привет1"
mage/customer/dashboard - "Hello", "Привет2"
mage/payment - "Hello", "Привет3"

Translator should search this phrase at first in "mage/customer/dashboard", after that - in "mage/customer", then in "mage". If there aren't any - it should take the global phrase translation.

@piotrekkaminski
Copy link
Contributor

We are working on improving it (or restoring lost functionality). It will allow per module translations which should solve most of the use cases
Internal issue id: MAGETWO-43683

@mazhalai
Copy link
Contributor

@nja78 a fix for this issue has been merged a while back, so we are closing this issue for now. Please open a new issue if you are still experiencing problems.

magento-team pushed a commit that referenced this issue Oct 7, 2017
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

6 participants