adium/adium

6194bf1c1f66
Update version number in Info.plist. Add a ticket number to Changes.txt.
{\rtf1\mac\ansicpg10000\cocoartf102
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fswiss\fcharset77 Helvetica-Oblique;
}
{\colortbl;\red255\green255\blue255;}
\paperw11905\paperh16837\margl1440\margr1440\vieww11440\viewh9560\viewkind0
\pard\tx565\tx1133\tx1700\tx2266\tx2833\tx3401\tx3967\tx4535\tx5102\tx5669\tx6235\tx6802\ql\qnatural
\f0\b\fs24 \cf0 How to make an Adium plugin localizable, for developers
\f1\b0 \
\
\f0\b 1. Strings in code
\f1\b0 \
\
In order to make the code localizable, you need to replace hardcoded strings with the following macro:\
\
AILocalizedString(theString,theComment)\
\
Replace
\f2\i theString
\f1\i0 with the original string, so for example:\
\
NSString *theExampleString = @"this is an example";\
\
becomes,\
\
NSString *theExampleString = AILocalizedString(@"this is an example", "this is a comment");\
\
You can leave the comment out by putting
\f2\i nil
\f1\i0 , it is not really needed. But it will show in the localization files that eventually will end in translators hands, so adding a bit of context for the string is a plus.\
\
The macro works this way: if looks for the current language resources folder, and load the
\f2\i Localizable.strings
\f1\i0 file from there and look for the key string (the string in English) and then use the left value of the dict (the file is actually a key-value pair dictionary). If there is no file, it just uses the key value, so it is safe to use the macro even if you have not set up a localization folder scheme. It also allows the use of the CLI utility
\f2\i genstrings
\f1\i0 to scan the source file and generates the initial Localizable.strings file for you.\
\
\f0\b 2. Make a Localizable.strings file
\f1\b0 \
\
Once you have all your hardcoded strings done with the macro, read above, you can generate the proper strings file and include it in the project file. Open up Terminal.app, type "cd " (that last thing is a space) and drop your plugin folder on top of the Terminal window. Hit enter, and then type this:\
\
genstrings -a -s AILocalizedString AIYourPlugin.m\
\
And hit enter, replacing
\f2\i AIYourPlugin.m
\f1\i0 with your source code file name, and repeating the command if you have several source code files with AILocalizedString strings. That will generate a
\f2\i Localizable.strings
\f1\i0 file in your plugin directory, you should take a look at it in case some strings got duplicated, which can be the case, and you can delete them.\
\
Time to add the file to the project. Add it, and remember to assign it to the plugin target, and not adium itself. Once it is added, select it in the file browser and select
\f2\i Show Inspector
\f1\i0 from the
\f2\i Project
\f1\i0 menu. And in the inspector pane that appear, click on the
\f2\i Make Localizable
\f1\i0 button. That will make a new folder in your plugin's folder (named English.lproj) and move the
\f2\i Localizable.strings
\f1\i0 file inside that folder.\
\
\f0\b 3. Make localizable nibs
\f1\b0 \
\
The last step to make your plugin localizable is to set up the nibs. All you have to do is select the nib in the file browser of Xcode, select
\f2\i Show Inspector
\f1\i0 from the
\f2\i Project
\f1\i0 menu and hit the
\f2\i Make Localizable
\f1\i0 button that appear in the inspector pane. That will move the nib to the English.lproj folder made in the previous step.\
\
And that's all. If you add new strings in the code you may need to repeat step 2. Look forward for another tutorial on how to actually translate the plugins.}