Localization policy
Содержание
RPM Macros
%lang
A file can be flagged %lang(LANG). This means it will only be installed if LANG is in %installlangs:
$ cat /etc/rpm/macros %''install''langs en:fr:ja
Normally, you should not mark files by yourself. You should always use %find_lang which should do everything for you.
%find_lang
Use macro %find_lang to collect and mark locale-dependent files.
Synopsis:
%find_lang name [filelist]
The macro %find_lang searches the directories /usr/share/locale and /usr/share/locale/*/LC_MESSAGES for name.mo files. It also searches gnome/help/name and kde/share/doc/HTML/'/name directories for a localized documentation. Then it creates the file filelist where the files are marked by the respective %lang(locale) tag and also by the %doc tag. Such a file list can be then passed to the %files tag via -f option. See below for an example.
The optional filelist defines the name of the file where the generated list of files is stored. name.lang is used if not defined.
Example:
%install ... %find_lang %{name} # generate a special file list ... %files -f %{name}.lang # use the special file list %defattr(-,root,root) # list the other files %doc README ...
Explicit %lang
In some cases, you may need to add things not handled by %find_lang. Example from numlock.spec:
%files %defattr(755,root,root) ... %lang(cs) /usr/X11R6/man/cs/man1/* %lang(et) /usr/X11R6/man/et/man1/* %lang(eu) /usr/X11R6/man/eu/man1/* ...
%lang drawback
When adding a language on a installed system, the %lang flagged files in already installed packages are not added. This is why localedrake only propose languages chosen during installation.
One package per language
%lang is quite nice for "not too big" language dependent files. When the size is quite big, it's interesting to create separate packages:
- to reduce the size of the package when one install over network
- to allow users to choose which l10n packages to mirror
- to create distributions with only the wanted l10n packages
The per language package should:
- be named alike openoffice.org-l10n-LANG or man-pages-LANG, where LANG is the locale name (eg: fr, pt_BR...)
- provide a virtual package alike openoffice.org-l10n or man-pages-l10n or aspell-dictionary (this allow Suggest: aspell-dictionary, !! work in progress !!)
- require the corresponding locale, to allow a simple heuristic to choose the best package (eg: if locales-fr is installed, choose aspell-fr because aspell-fr requires locales-fr)