DNS
DNS

Reputation: 38199

Is there a naming convention for locale-specific static files?

I have some static resources (images and HTML files) that will be localized. One piece of software I've seen do this is Apache, which appends the locale to the name; for example, test_en_US.html or test_de_CH.html. I'm wondering whether this naming scheme is considered standard, or whether every project does it differently.

Upvotes: 5

Views: 4826

Answers (3)

blahspam
blahspam

Reputation: 951

While there is no documented standard for naming Localized files, I'd recommend using the format filename[_language[ _country]] where

  • language is the ISO-639 2 letter language code
  • territory is the ISO-3166 2 letter country code

For example:

  • myFile.txt (non-localized file)
  • myFile_en.txt (localized for global English)
  • myFile_en_US.txt (localized for US English)
  • myFile_en_GB.txt (localized for UK English)

Why? This is the most typical format used by operating systems, globalization tools (such as Trados and WorldServer), and programming languages. So unless you have a particular fondness for a different format, I see no reason to deviate from what most other folks are doing. It may save you some integration headaches down the road.

Upvotes: 12

odysseus
odysseus

Reputation: 1

You should always use the "de-facto" standard, which is the unix/posix way with gettext. And you shoud use gettext to make your localization!

Therefore one and only correct way is to use localization naming like this:

en
en_US
en_UK

Some applications and especially Java developers ar sometimes using the en-US (hyphenated instead than underscored) and it is ALL WRONG!!!

gettext standard is this and only this:

locale
 |_en_US
    |_LC_MESSAGES
      |_appname.mo

Where:

locale - Name of the directory, can vary but it is highly recommended to stay with "locale"-name

en_US - Any standard locale like *es_ES*, *es_PT*, ...

LC_MESSAGES - mandatory and cannot be changed!

appname.mo - msgfmt compiled appname.po file (appname is what ever you want)

Upvotes: 0

Ben Blank
Ben Blank

Reputation: 56604

While there doesn't appear to a standard conventions as to where in the file name to place them, the international codes for language (e.g. "en") and region (e.g. "en-US") are both very common and very straightforward. Variations I've seen, excluding "enUS" vs. "en_US" vs. "en-US":

  • foo.enUS.ext
  • foo.ext_enUS
  • enUS.foo.ext
  • foo/enUS.ext
  • enUS/foo.ext
  • …ad nauseum

I personally favor the first and last variants. The former for grouping files by name/resource (good for situations in which a limited number of files need localized) and the latter for grouping files by locale (better for situations with a large number of localized files).

Upvotes: 1

Related Questions