简体   繁体   English

Gettext和语言环境

[英]Gettext and locales

I heard from a relatively trustworty source that gettext doesn't require system locales for it to work. 我从一个相对可信任的消息来源得知,gettext不需要系统语言环境即可运行。 But I have tried a few tutorials, and unless I have locale-gen'd (in arch) fi_FI.utf8, I can't get any translations to show. 但是我已经尝试了一些教程,除非我有基于语言环境的(在拱形中)fi_FI.utf8,否则我将无法显示任何翻译。

root@junior:~/programming/Projects/Cpp/web/test# LANG=fi_FI.utf8 bin/hello 
Hello world!
This is package: web-cms
root@junior:~/programming/Projects/Cpp/web/test# sed -i 's/#fi_FI.UTF-8/fi_FI.UTF-8/' /etc/locale.gen && locale-gen
Generating locales...
  en_GB.UTF-8... done
  en_US.UTF-8... done
  fi_FI.UTF-8... done
Generation complete.
root@junior:~/programming/Projects/Cpp/web/test# LANG=fi_FI.utf8 bin/hello 
Terve maailma
Tämä on paketti: web-cms

Did you hear right? 你没听错吗? As far as I know, you do need system locales for gettext to work. 据我所知,您确实需要系统区域设置才能使gettext起作用。 However, you do not need to install all the translations for those system locales just to make your "hello world" work. 但是,您不需要仅为使“ hello world”工作而为这些系统语言环境安装所有翻译。

setenv("LANGUAGE", languagecode);

如果languagecode是“ fr”,并且bindtextdomain指向的目录中有一个“ fr / LC_MESSAGES / .mo”文件,则该文件应该可以工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM