diff options
author | David Robillard <d@drobilla.net> | 2008-11-08 19:53:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-11-08 19:53:30 +0000 |
commit | 0ff919f9b56903952aa76cd0315ccb808a7bd59c (patch) | |
tree | dca34d4f06f74fdea189e36f256dec071c9e4d0d /src/util.c | |
parent | f6e5dcc1a59c4d4103718d3dbf3ee77096eeaa88 (diff) | |
download | lilv-0ff919f9b56903952aa76cd0315ccb808a7bd59c.tar.gz lilv-0ff919f9b56903952aa76cd0315ccb808a7bd59c.tar.bz2 lilv-0ff919f9b56903952aa76cd0315ccb808a7bd59c.zip |
Support i18n literals via LANG environment variable.
Apply patch from larsl (ticket #186).
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@1705 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -71,4 +71,27 @@ slv2_uri_to_path(const char* uri) } +char* +slv2_get_lang() +{ + static char lang[32]; + lang[31] = '\0'; + char* tmp = getenv("LANG"); + if (!tmp) { + lang[0] = '\0'; + } else { + strncpy(lang, tmp, 31); + for (int i = 0; i < 31 && lang[i]; ++i) { + if (lang[i] == '_') { + lang[i] = '-'; + } else if ( !(lang[i] >= 'a' && lang[i] <= 'z') + && !(lang[i] >= 'A' && lang[i] <= 'Z')) { + lang[i] = '\0'; + break; + } + } + } + + return lang; +} |