2

I tried to add a translation on :

app/design/frontend/Theme/theme/Magento_Ui/web/templates/form/field.html

I added a translation like this :

<div class="gotcompany" data-bind="i18n: 'Got a company'"></div>

My i18n file is here :

app/design/frontend/Theme/theme/i18n/fr_FR.csv

The translation does not work with 'Got a company', if I use 'Sign In' it works, I tried to change the text of Sign In to be where the translation come from, it works too

Configuration :

"Got a company","test entreprise",module,Magento_Customer
"Sign In","Se connecter",module,Magento_Customer

I also tried Magento_Ui for reference with no success

Need your help please

2 Answers 2

0

Translation loading order by highest priority is:

  1. Database (saved in translation table)
  2. Themes (app/design/i18n folder)
  3. Language packages (app/i18n/[Vendor_Name]/xx_yy folder)
  4. Module (app/code/[Vendor_Name]/[Module_Name]/i18n folder)

You are using translate by theme which can be overridden by Database. So, let's check if you or someone translated that string by Translate Inline Tool or not with the SQL query below:

SELECT * FROM translation WHERE `string` LIKE '%Got a company%';

If you found any result, let's remove that record.

8
  • templates can't be replaced by template, the folder name in module_ui is templates, there is also a template folder I tried also your two solutions, it doesn't work
    – Kevin ami
    Oct 26, 2022 at 9:33
  • Can you see class gotcompany when inspecting elements ?
    – Tu Van
    Oct 26, 2022 at 9:39
  • Do you mean you've tried this in your html file and the translation work? <div class="gotcompany" data-bind="i18n: 'Sign In'"></div>
    – Tu Van
    Oct 26, 2022 at 10:29
  • Yes I can see Class gotcompany, it show in inspector <div class="gotcompany" data-bind="i18n: 'Sign In'">Se connecter</div> but with 'Got a company' magento giving me <div class="gotcompany" data-bind="i18n: 'Got a company'">Got a company</div>
    – Kevin ami
    Oct 26, 2022 at 10:53
  • I also Tried "Got a company","test entreprise" without module reference, but it's not working too.. I do not understand why
    – Kevin ami
    Oct 26, 2022 at 10:54
0

It seems that finally this is a problem of Magento core (Thanks of Tu Van who helped me), you can force the translation by declaring mage/translate

define(['jquery','mage/translate'], function($){

and then calling the translations, also in the js file

$.mage.__('Got a company')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.