Resource editors

I decided to use ResourceBundles to provide translations for my php application. Although the functionality of ResourceBundle (http://www.php.net/manual/en/class.resourcebundle.php) is completely new, I prefer how it works on gettext.

I have a question: are there any good ResourceBundle editors? In particular, I am looking for one that will check all of my source files and generate a list of message identifiers that require translation and / or updating.

I used to use POEdit to generate translation files for gettext. It is able to scan the source files for functions such as _ (), and pass me a list of message identifiers for translation.

I tried installing the eclipse plugin (http://sourceforge.net/projects/eclipse-rbe/), and although it has a nice graphical interface, it does not scan my source files to create a list of message identifiers for translation.

Can anyone recommend resource pack editors?

+4
source share
2 answers

After spending most of the day trying to find many different tools, and what’s not, I developed this workflow and how much it will help others.

ResourceBundles are fairly new to PHP, and there is not much information. Surprisingly, while resource packs have long been used in different languages, such as Java, I could not find any tools that could handle RB in a general way.

SirDarius's suggestion to try RB Manager was a good start. It directly uses, but there are some problems:

  • To scan the source code, you need to configure the scanner using an XML file, which may be unintuitive.
  • More importantly, the scanner will report a list of unused keys and new keys. They still need to be manually added to your resource packages using the RB Manager main application.
  • Finally, ICU files exported by RB Manager are violated. When content needs to be exported as soon as the content itself, somehow RB Manager converts them to the decimal equivalent of the ASCII code. This makes the file unusable.

I tried to use various tools for converting between formats, namely the XLIFF format, but I found that the generated XLIFF files are often distorted, and the next piece of software refuses to process it.

For those who may encounter this problem in the future, here is what I did:

  • I assume that you will have some classes or functions to wrap the MessageFormatter and ResourceBundle classes. In my application, I use something like $translate->_('text'); to complete the transfer. The trick is to use POEdit. POEdit scans the source files for _ () and obtains a list of keys and deletes old keys. Remember that in MessageFormatter you use only the message identifier, for example system.warning.reason, and not the full line "Your action was rejected. This has been logged."

  • Then you should use POEdit to write your translations. Working with multiple values ​​is slightly different. You should not set any rules for working with plurals. Multiple values ​​are performed in a string for a translation string, which is truly flexible. See here: http://userguide.icu-project.org/formatparse/messages for some examples.

  • Once your translation is complete, I wrote a small PHP script to convert the POEdit generated .mo files into equivalent ICU files. To parse .mo files, I used the gettext adapter in Zend_Translate.It also contains a function to capture all message and message identifiers, which is extremely useful. Then you convert this data to ICU format as follows:

     root { // message ID {" Pattern "} system.warning.reason { "Your action was denied. This has been logged" } } 

Once this is done, you need to download the ICU package from: http://site.icu-project.org/download . In the bin directory, you will find the genrb executable that compiles the resourcebundle into a binary for use by PHP.

The genrb inputfile.txt -e UTF-8 command genrb inputfile.txt -e UTF-8 notes that the input encoding is specified as UTF-8. You can change this to any encoding used by your input files.

What is it. I believe this is the easiest and most efficient workflow for creating and translating resources for PHP.

If someone comes up with a better way or even a complete standalone program to take care of this, write a comment!

+6
source

You can try the following: http://icu-project.org/download/rbmanager.html

A Bundle Resource manager written for the ICU project on which the PHP resource bundle class is based.

0
source

All Articles