translatephpmessage Manage translations with CPhpMessageSource

  1. Manage translations with CPhpMessageSource
  2. Requirements
  3. Configuration
  4. How to use
  5. Options Usage
  6. About escaping
  7. Resources
  8. Change log

Manage translations with CPhpMessageSource

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.

Requirements

Tested with Yii 1.1.13 and PHP 5.4.

Configuration

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).

How to use

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:

<?php
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, scroll to the bottom until you find a table labeled 'Insert new line for default language'.

Options Usage

  • 'encoding' => 'UTF-8' change to the encoding you want to use, defaults to UTF-8
  • 'excludedirs' => array() directories to exclude, list like this: array('.git', 'otherdir')
  • 'excludefiles' => array() files to exclude, use like this: array('.gitignore', 'otherfile.php')

About escaping

TranslatePhpMessage uses PHP var_export to save the file.
var_export does all the escaping in order to not break the array.
Usage of HTML character entity will work (&copy; &#169; copyright sign).
HTML tags (<div></div>) will not.

Resources

Change log

0.5 09/07/2013

  • changed string escape method, now using PHP var_export
  • fixed missing file creation
  • should now present valid error message when no directories are found

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
9 0
18 followers
1 073 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Kajo
Created on: Feb 27, 2012
Last updated: 11 years ago

Downloads

show all

Related Extensions