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 is Apache, which adds a locale to the name; for example, test_en_US.html

or test_de_CH.html

. I'm wondering if this naming scheme is considered standard or if each project does it differently.

+2


a source to share


3 answers


Although there is no documented standard for naming localized files, I would recommend using the [_language [_country]] filename format where

  • language - ISO-639 two-letter language code
  • territory - ISO-3166 two-letter country code

For instance:



  • 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 English in UK)

What for? It is the most common format used by operating systems, globalization tools (such as Trados and WorldServer), and programming languages. Therefore, unless you have a particular attachment to another format, I see no reason to deviate from what most other people do. This can save you future integration problems.

+9


a source


While there is no standard convention for where in a file name to place them, international codes for language (for example, "en") and region (for example, "en-US") are very common and very simple. The variations I've seen excluding "enUS" versus "en_US" versus "en-US":

  • foo.enUS.ext
  • foo.ext_enUS
  • enUS.foo.ext
  • Foo / enUS.ext
  • Enus / foo.ext
  • ... ad nauseum


I personally endorse the first and last options. The former is for grouping files by name / resource (good for situations where a limited number of files are required) and the latter is for grouping files by language (better for situations with a large number of localized files).

+1


a source


You should always use the de-facto standard, which is the unix / posix way with gettext

. And you use gettext

to do your localization!

Therefore, the one and only correct way is to use localization names like this:

en
en_US
en_UK

      

Some applications and especially Java developers sometimes use en-US

(hyphenated instead) and this is ALL WRONG !!!

gettext standard is this and only this:

locale
 |_en_US
    |_LC_MESSAGES
      |_appname.mo

      

Where:

locale

- Directory name may change, but it is strongly recommended to stay with "locale" -name

en_US

- Any standard language such as * es_ES *, * es_PT *, ...

LC_MESSAGES

- mandatory and cannot be changed!

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

0


a source







All Articles