Reputation: 7048
When you create a PHP script which outputs text and you want to be able to let the user of the script set the language, what's the best format for a language file?
Keep in mind that the user of the script will need to be able to change some words in the language file, so the easier the better.
Upvotes: 1
Views: 1460
Reputation: 99909
gettext
is often used for two reasons:
many tools
to help translating with this formatThe way to translate a string is to call the _()
function like this: _("some text")
.
An other format that's easy to parse with PHP is ini files
.
Upvotes: 2
Reputation: 15381
Don't forget YAML.
The answer is that it depends on your data. CSV is very convenient if you're outputting a list of records where each field in the record is a simple value. But CSV gets troublesome if records have hierarchy in them or if fields can have multiple values.
For representing hierarchy, relationships, or multiple values, XML, JSON, and YAML are the most appropriate. Of these, XML is the most verbose, which is why I tend not to like it. I find YAML fairly readable without being too verbose.
Upvotes: 1
Reputation: 68006
.properties file is probably the simplest kind of configuration, if I understand the question correctly.
E.g.,
language = en
time = 18:00
Lots of languages have standard libraries to read those.
Upvotes: 1