Rubens Cury Posted April 17, 2015 Share Posted April 17, 2015 I'm looking for a way to translate my module fieldnames in order to allow to update them from the regular BO Translation tools. The PS DOC says only the /classes/* files are available for. May I conclude that it's impossible for a module? Field names translationThe following folder is parsed: /classes/ and all of its sub-folders.The string are those returned by the getValidationRules() method from ObjectModule for each class. All the field names translations are stored in the following file, with iso_code being the ISO 3166-1 code (http://www.iso.org/iso/country_codes.htm) for the language of the translated strings (de, fr, en, it, es, etc.): /translations/iso_code/fields.phpThe translations are stored in a PHP array, named $_FIELDS, and take the following form: $_FIELDS['Address_2df2ca5cf808744c2977e4073f6b59c8'] = 'Téléphone mobile';The identification key is built by combining the name of the class from which the string comes, an underscore, and the MD5 hash of the string itself. Link to comment Share on other sites More sharing options...
electriz Posted April 20, 2015 Share Posted April 20, 2015 What about Localization > Translations and select Type of translation "Installed modules translations". Find your module and there should be strings to translate. Link to comment Share on other sites More sharing options...
Dev Franco Posted April 20, 2015 Share Posted April 20, 2015 Hi, Anybody Please explain how to do module templates translation. In my module, I have used the {l s="text_to_translate" mod="mymodule"} format. Then through admin, localizattion->translation->modify translation , I have selected 'installed module translation' and the language into which to be translate. But I can't see the texts to be translated under mymodule. What's wrong with this?Do I missed anything?Plz help Link to comment Share on other sites More sharing options...
electriz Posted April 20, 2015 Share Posted April 20, 2015 You are using correct syntax. Do you have checked Force compilation in Advanced parameters > Performance ? Link to comment Share on other sites More sharing options...
Dev Franco Posted April 20, 2015 Share Posted April 20, 2015 Hi electriz, The issue is fixed now. when I changed the double quotes in {l s="text_to_translate" mod="mymodule"} into single quotes it worked. I don't know whether using double quotes is wrong or not. But {l s='text_to_translate' mod='mymodule'} is worked for me. Thanks Link to comment Share on other sites More sharing options...
electriz Posted April 20, 2015 Share Posted April 20, 2015 I'm using single quotes, but it's strange you couldn't use double quotes... Anyway, good to hear you solved it Link to comment Share on other sites More sharing options...
Rubens Cury Posted April 20, 2015 Author Share Posted April 20, 2015 (edited) Hi Electriz, Thank you for your reply, however, I'm not looking for a way to translate my inputs texts module but the TABLE FIELDS (firstname > Translated firstname) in order to display translated and friendly validation errors messages. Please, check the FIELD NAME TRANSLATIONS to see what kind of things I'm trying to translate. Tks Edited April 20, 2015 by Rubens Cury (see edit history) Link to comment Share on other sites More sharing options...
electriz Posted April 21, 2015 Share Posted April 21, 2015 So, do you want to add translated field names to translated validation error messages? Link to comment Share on other sites More sharing options...
Rubens Cury Posted April 21, 2015 Author Share Posted April 21, 2015 Exactly. Instead of display something like fields_name is required I wish to display friendly_name Link to comment Share on other sites More sharing options...
electriz Posted April 22, 2015 Share Posted April 22, 2015 Ok, so I guess you try to do it in .tpl file in front office. Let's make an example for email field. You can use {$smarty.post.email} to retrieve a POST value and if it does not match validation, display a message. For example, if email is empty. {if isset($smarty.post.email)} Ok {else} {l s='Please type something in' mod='mymodule'} {l s='email' mod='mymodule'} {l s='field' mod='mymodule'} {/if} And you can do the same for another fields. Link to comment Share on other sites More sharing options...
Rubens Cury Posted April 22, 2015 Author Share Posted April 22, 2015 Indeed, I'm developing a BO Module. My solution was handle by the postProcess controller method each required field and display my custom message for them. For all the others not handled fields I decided to keep displaying the Prestashop core's auto translated - by default - error messages. Doing that, the only problem I would still have is display the TABLE FIELD NAME instead of a custom field name, once users don't have to know the exactly table field meaning. Thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now