From Mandriva Community Wiki
rpm supports translation of description (though less documented) with -l option after %description. For summary and group, the format is adding ISO639 language code with parenthesis before colon (more info here), like:
- Summary: summary
- Summary(fr): sommaire
- %description pkg
- This is text.
- %description -l fr pkg
- C'est texte.
This is proven to be a nightmare, since packagers use their own encoding of choice, leaving a multiple-encoded file as result. Such a spec file can't possibly be handled properly by any editor if more than one translation exists. Thus for description or summary translation, po file is the way to go.
Since in most such cases Mandriva spec is using ISO-8859-1 encoding, I'm using that as an example.
Anyway such translations are forbidden by policy. Summary translations myst be done in the mdv-rpm-summary package.
Problematic to read your file
Everybody has their own system, and they may not migrate because the old encoding "just works". However, lots of the encodings in this world are not compatible with each other. Their only common part is ASCII characters (so ASCII is safe for spec files). ISO-8859-1 characters are only shown as junk for other locales.
This, of course, requires both of writer and reader to migrate to UTF-8; but a fair amount of users are starting to do so, and you will get more help from people all around the world. Otherwise, people would less likely help because what you code or write is unreadable -- unless your intention is exactly not expecting others to help.
Editors may damage spec file
Related to the first point but worse. For systems with non-ISO-8859-1 legacy charset, text editors may not handle the "junk" text, and may even attempt to "correct" it by modifying characters, rendering the file even more broken.
How to fix?
In spec file itself
It is the spec file that matters, so remember to use UTF-8 throughout the file. To test if your spec file is indeed in UTF-8, use iconv to filter it:
iconv -f UTF-8 -t UTF-8 -o /dev/null yourpackage.spec
If it doesn't complain, the file is in UTF-8 (or ASCII). Otherwise it will tell you the UTF-8 test is broken in which position; you can also remove =-o /dev/null= argument to have a look yourself.
In various config files
Remember to use UTF-8 in ~/.rpmmacros, from where your name is read (in %packager line):
- %distribution Mandriva Linux
- %vendor Mandriva
- %packager José Huang <email@example.com>
If you also use rebuild-rpm and similar building tools, please remember to change your name in the corresponding config files too.
UTF-8 enabled editors
There are many text editors that support UTF-8 natively, be it GUI one or text mode one.
Use UTF-8 in your shell environment too whenever possible, that would eliminate lots of headaches. For example, this is my locale setting from locale command:
You can change language settings in the ~/.i18n file located under your home directory.