|Language:||English, Spanish, French|
|Distribution:||Free* [*Registration Required]|
Also, to help you not get messy over the command-line, we will be presenting a great GUI application that can be used to easily update your l10n source Other tools There are common libraries used that support Gettext and other implementations of i18n. Some of them may seem easier to install or sport additional features or i18n file formats. It uses array formats for message.
However, it has no message extractor. Other frameworks also include i18n modules, but those are not available outside of their codebases: Laravel supports basic array files, has no automatic extractor but includes a lang helper for template files. Yii supports array, Gettext, and database-based translation, and includes a messages extractor.
It is backed by the Intl extension, available since PHP 5. If you decide to go for one of the libraries that provide no extractors, you may want to use the gettext formats, so you can use the original gettext toolchain including Poedit as described in the rest of the chapter. Gettext Installation You might need to install Gettext and the related PHP library by using your package manager, like apt-get or yum.
Here we will also be using Poedit to create translation files. Structure Types of files There are three files you usually deal with while working with gettext.
Domains There are some cases, in big projects, where you might need to separate translations when the same words convey different meaning given a context. In those cases, you split them into different domains. In Symfony projects, for example, domains are used to separate the translation for validation messages.
Locale code A locale is simply a code that identifies one version of a language. It is defined following the ISO and ISO alpha-2 specs: two lower-case letters for the language, optionally followed by an underline and two upper-case letters identifying the country or regional code. For rare languages , three letters are used. For some speakers, the country part may seem redundant. Directory structure To use Gettext, we will need to adhere to a specific structure of folders.
First, you will need to select an arbitrary root for your l10n files in your source repository. Plural forms As we said in the introduction, different languages might sport different plural rules.
For uploading a file we need a form for the user to enter the file name or browse their computer and select a file. Example : upload. It's to restrict the size of files. You should not assume that the file was uploaded successfully to the server.
Always check to see if the file was successfully uploaded by looking at the file size. If it's larger than zero byte then we can assume that the file is uploaded successfully.
Our next job is to read the content of this file and insert the content to database. Always make sure that you use addslashes to escape the content. Using addslashes to the file name is also recommended because you never know what the file name would be.
That's it now you can upload your files to MySQL.
Now it's time to write the script to download those files. These were not needed for uploading the files but is needed for downloading the files from the database. The download page list the file names stored in database. The names are printed as a url. The url would look like download.
To see a working example click here. I saved several images in my database, you can try downloading them. We can use this id to identify which files to get from the database.
They are : 1.