This module creates a user interface to translate your message files.
Your application must be setup to use messages CPhpMessageSource.
Check Resources for links with information about this.
Tested with Yii 1.1.10.
Edit your config file and add or change these lines:
......... 'modules'=>array( ......... 'TranslatePhpMessage' => array( 'encoding' => 'UTF-8', //encoding used to save messages 'excludedirs' => array(), //directories to exclude 'excludefiles' => array(), //files to exclude ), ......... ), ......... // default Yii language, CHANGE to your language 'language' => 'en_us',
Every directory under /protected/messages/ should have 777 permissions (Unix only).
Extract the file to protected/modules.
Create a link to '/TranslatePhpMessage') or navigate to index.php?r=TranslatePhpMessage
This module assumes that the developer mantains the default language files, all operations are based of that files, so keep them in order.
The module displays an error if it cant find the directories where message files are stored.
Ideally you will have at least two directories (default language, other language).
If not you will get a warning, until you create them manually, there isn't any functionalty for that.
Choose the language you want to translate. You can choose the same language as the default to edit a source file.
The next screen shows two lists of files.
On the left the files you have. If you need a new file you must create it manually
On the right shows what files are missing (you can create a new blank file).
Again, this lists refer to the default language, so no missing files will show if you are editing the default language.
If you need a file not found on either list you must create it manualy in the default language directory.
Just make sure the file contains:
return array()
The translate view compares between your default language and the language you choose.
To translate just write on the translation column and save.
You can also insert new key=>value pairs in the default language message file
0.4 02/04/2012
- add option to exclude files / directories from the listing
- some settings can now be changed from config file
- solved bug under linux where filepath was wrong
0.3 02/03/2012
- Should work under Linux with no errors (Windows is ok).
0.2 29/02/2012
- no longer gives errors with PHP error reporting other than server production settings
- more helpful error messages
- UI tweaks
0.1 27/02/2012
- initial release
Total 3 comments
.... would be nice features because the translation files could have a lot of entries. nice tool that works for me, thanks
Hi Befi,
Thank you for the time spent reviewing this module.
Your suggestion for the hidden directories makes a lot of sense, I've implemented it slightly different but now you can choose wich file/directory to exclude from list. You can still exclude .svn but still include (for whatever reason) other hidden directories. It's also possible to exclude any directory you want.
Did the same for files which I actually needed.
You anticipated my reply with your edit, but if you don't want the new version (0.4), then instead of changing
languagesNames()changefindLanguages()instead with the same edit you used forfindFiles().As for the
addslashesis not as simple, did you tried to enter:e\'it will save as
e\\'which will broke the array.I'm working with SVN so I immediately noticed that the ".svn" directory is included as well. It makes sense to exclude hidden directories. I did so by using
instead of
in the findFiles function in TranslatePhpMessageModule.php and
using
in front of
in languagesNames() in the same file.
Hope this helps!
Otherwise great module!
[EDIT]
I did some more work with it and it's actually not a good idea to use "addslashes" since this function escapes quotes, double quotes and the backslash. It's to escape strings for database insertion if you don't have the DBMS specific escape function at hand. That's not what you want in this case. Since we're writing a PHP array with strings to a file and we're enclosing each string (key and value respectively) with quotes ('this is a string'), escaping double quotes and backslashes is unnecessary.
Therefore I would suggest an array2text function like this:
With this, you can savely use ', " and \ in your strings without side effects.
Leave a comment
Please login to leave your comment.