Internationalization of Codeigniter PHP application using an excel spreadsheet - php

I have a web app built on top of codeigniter. It's primarily in English but now I want to add support for other languages as well.
I'm familiar with Codeigniter's language library:
http://codeigniter.com/user_guide/libraries/language.html
Which seems like a pretty good solution, however I have one problem. For each language, you must create a separate file of $lang[KEY] = VALUE statements. This means that if I want to have my Spanish speaking friend help me translate my application, they have to have the other file open next to the one they're working on. It can be pretty easy to lose track of your position.
I would like to translate this using a spreadsheet (csv) approach, picture something like this:
What are some ways I might go about accomplishing this? I've considered creating a 'master' spreadsheet for the application, and then writing a command-line php program to parse the csv file and create the appropriate language files which I would insert into my application. Is there a better way?

Did you take a look at this? http://codeigniter.com/wiki/LangBuilder

Related

Localization file for JS and PHP

I did some search about localization files, see that we can use .po file or gettext but, is there any tutorial or sample of a unique solution that will work both in javascript and in php.
I want to only maintain one localization file per language that will work with both JS and PHP languages.
Would appreciates if someone can point me to some links or samples...
I found that it is typically a sign of a questionable design when translatable text is coded inside JS functions. JS is meant to implement logic, not content. The content should be provided by PHP (typically by using a templating engine) and should be used by JS. That way you only need a localization solution for PHP.
If (exceptions always occur) you really need to translate a phrase inside a JS routine you use an ajax call to fetch the translation. This also simplifies the access to the dictionary holding the translation tokens since it is again done by PHP. The dictionary can be kept in a single place.
Yep, there is. I've successfully used gettext.js a while ago, which is operating on .json or .po files. This way, you only have to maintain one translation source. The webpage I've used this for is located here so you can check out how I've did it. Good luck!
First, try to avoid gettext if you can. It's popular and stable, but it puts some burden on the translations maintenance: you will need to change the source strings, and when this happens, gettext needs to update all the message keys, and this may mess up the existing translations. An approach with constant message keys is much easier to maintain in the long run - you will need to remember to delete the keys you don't use any more, but it's a very small burden.
You can use the same translations storage format for PHP and JavaScript. If you use a key-based approach, as I suggest, it will probably be some JSON-based format. JSON is easily accessible in both PHP and JavaScript.
There are several ready-made JavaScript libraries for JSON-based internationalization. I happen to be a developer of one such library: https://github.com/wikimedia/jquery.i18n . It should be reasonably easy to adapt it to PHP.

Can I parse hg19.2bit with php?

I know this is possibly an obscure use for php, but I'm working on an idea to navigate the human genome in a rather interesting way.
The problem is I need to know if I can write a php script to parse the freely available data, and if so how would I start? Are there any php scripts to do this in existence?
I'd suggest creating a database design (MySQL) that has the subset of data you want to explore in the PHP application.
Then find a way to upload the data into that data schema. For the uploading part you could use a more poweful language than PHP of your choice, it could be C#, F#, Haskell, or whatever.
This seperation will help simplify things more than doing it all in PHP.
You'll have to write a parser for that, but that should be fairly simple:
http://jc.unternet.net/genome/2bitformat.html
And an example in Perl: http://www.perlmonks.org/?node_id=672251

Extract translation phrases from Magento

I'm relatively new to Magento and working on a site build for a client and they simply need a list of phrases used throughout the site to be sent to a translator. I'm a little surprised that there isn't something simple and built into Magento for easily pulling this stuff out, which is why I'm writing here now. Is there a relatively simple way to extract translation phrases from a Magento app? Something built in that might not be obvious (to me)? or some useful library out there? This includes everything used in the templates (or controllers) like so:
$this->__("Some phrase on my website...");
... as well as cases in the layout XML where the 'translate' attribute is set, etc.
And taking this one step further, I'm aware of the available translations available from Magento here: http://www.magentocommerce.com/translations -- is there something simple to make sure I'm not double-doing it for phrases that might already exist in these packs?
And further still, is there a something to pull all translatables out of the database?
And if the answer for all this turns out to be 'no', I need to be very thorough with this so any advice on pitfalls or particular spots I need to be aware of where I might not think of pulling translations from, how you might have achieved something like this before, etc. -- I would love to hear your tips. Thanks!
I know I'm late, but anyway, I’ve just uploaded an extension that does that: Language CSV Files Generator.
It only extracts strings from .php and .phtml files, I have no idea of how to get the .xml ones. Hope that someone out there could share some idea.
hope you like it
Take a look in /app/locale/(language_country)/*.csv files.
There are different solutions to get the strings from CSV files of Magento:
check the links The Ultimate Guide to Translating Magento (using Translation Memory software)
and How to translate Magento using OmegaT software

Which option is more scalable?

I'm working on php, mysql on a project
I'm planning to add a multilanguage option, usually I use single textfile for each php file, but I want to know if one of the followings is good or not and why.
Using one single textfile for the whole site: This would make my life peacefully because I have to make changes in one place only, but I don't know how scalable this option would be.
Using xml files for each php, is this scalable for dictionaries?
Using one single xml file, is this scalable for dictionaries?
Using a table in the db, I used this options a few times, but I read that it make the webpage slower and is not really scalable
That are my options, if any have a better one I would be greatfully, and if anyone have an advice on the pseudocode (I usually use a big array) and a replacement Welcome too :D
use gettext
wordpress is a good example if you need one
as for your question, separate language files is the only solution, letting many people work on different languages separately
I only use db when I need other people to add / modify datas in my translation.
Else I use a php file by language, defining my variables in each.

What's the most efficient way to setup a multi-lingual website

I'm developing a website that will be available in different languages. It is a LAMP (Linux, Apache, MySQL, PHP) setup, and it makes use of Smarty, mostly for the template engine.
The way we currently translate is by a self-written smarty plugin, which will recognize certain tags in the HTML files, and will find the corresponding tag in an earlier defined language file.
The HTML could look as follows:
<p>Hi, welcome to $#gamedesc;!</p>
And the language file could look like this:
gamedesc:Poing 2009$;
welcome:this is another tag$;
Which would then output
<p>Hi, welcome to Poing 2009!</p>
This system is very basic, but it is pretty hard to control, if I f.e. would like to keep track of what has been translated so far, or give certain users the rights to translate only certain tags.
I've been looking at some alternative ways to approach this, by either replacing the text-file with XML files which could store some extra meta-data, or by perhaps storing all the texts in the database, and retrieving it there.
My question is, what would be the best way to make this system both maintainable and perform well with high user-traffic? Are there perhaps any (lightweight) plugins I could take a look at?
You could give a shot at gettext. It is the way it is done in most C/C++ linux applications and it is an extension to PHP too. The idea is not very different from what you're already doing, but there are tools that ease the mantainance of translations (i.e. poedit).
For user rights to translations, gettext won't be of much help, I think you'll need to do it on your own or look at some frameworks if they have smarter solutions.
Maybe taking a look to gettext lib could help you get some hints http://php.net/manual/en/book.gettext.php hope it helps!
You will need to have a table in your database that you can use to store strings of text, each with an composite ID. the composite ID will be made up of language ID and text node ID.
You will need to give the user a chance to select a preferred language. You should make sure that you either have a default "this has not been translated" for every language you use, or a default language that your entire site can be vied in.
For every bit of text with in your web site, rather then store the text with in the page, you just assign it an ID.
When serving the page, look up the text node ID and preferred language ID and load that string of text, or the string for the default.
in our project, http://pkp.sfu.ca/ojs, we use XML files to store translation key-value pairs. Browse our code: http://github.com/pkp/pkp-lib/blob/master/classes/i18n/PKPLocale.inc.php
We use that class to read the XML files for each locale and in our code we use Locale::translate('locale.key.name');. Similar to gettext, but using an XML file for easier updating.
Looking around at web stuff today I came across this website: http://translateth.is/
It looks simple to use... copy paste in some javascript.

Categories