HowTo:Add a Language to the Mac Client
From iFolder
The iFolder Macintosh client is written in objective-c and uses standard Cocoa
i18n practices. The strings to be translated are located in two places. The
first place is the Localizable.strings file. This file contains all of the
strings used in the code outside of a .nib file. The second place is in the
individual .nib files. Now opening each .nib file and changing the strings
from english to the translated language would be more work than we are willing
to do so we've built in a build target that will extract all of the strings from
each .nib file so they can easily be translated and placed back into a
translated .nib file.
The first step is to open the iFolder.xcodeproj in Xcode and locate the Localizable.strings file in the Resources folder. Select the file and choose "Get Info" (cmd-i). Under the General tab you will see a Localizations table where you can add the language you want to add. Don't use the pre-defined choices, make sure you use the standard localization abbreviations (ie - Spanish = es). This will create a new .lproj folder in the OSXClient directory with the prefix of the local (adding a Spanish language would create es.lproj). You need to repeat those steps for each .nib file located in the Resources folder. You'll know a resource will handle your new language when you click the arrow next to the resource and see the local abbreviation show up under it. Make sure you also add the locale to the Credits.rtf file so the about box shows up translated and not in English. You'll also need to edit the Makefile.am located in the OSXClient folder and add your new .lproj directory to the LPROJDIRS variable so make will find it.
The next step is to generate .strings files for all the .nib files in preparation to be translated. You can manually open each .nib file in Interface Builder and add the translated strings but that's more work than we are willing to do so we added a build target to extract the strings from all of the .nib files. Run the following make command when in the OSXClient folder:
make generate-strings
The end result will be an updated Localizable.strings file and a .strings file for each .nib file located in the English.lproj folder. Ignore the errors about graphics, this happens because we have a common location for the graphics and they are not resolvable by the genstrings tool. Copy the .strings files to your new locale .lproj directory.
The format of a single string in the .strings file looks like this:
/* No comment provided by engineer. */ "Clear Log" = "Clear Log";
If this string were translated to spanish it would look like this (I have no idea if this is the correct translation, it's an example):
/* No comment provided by engineer. */ "Clear Log" = "Registro Claro";
Once all of the strings are translated, you can re-insert them into the .nib files by running the following make command from the OSXClient folder:
make update-strings
This command calls nib tool which is given parameters to leave the .nib file preserved as far as alignments but update the strings. You may have to open the .nib files and adjust the widgets to align with the new translated strings.
At this point the product is translated into your new locale and you can run the following command to clean up all of the extra .strings files which are no longer needed:
make clean-strings
Adding new strings and/or files
If you are adding strings to the code, you need to make sure you wrap them in the NSLocalizedString function. If I were adding the string "Checking for new iFolders..." it would look like this in code:
NSLocalizedString(@"Checking for new iFolders...", nil)
The second parameter is one you can use as a developer to provide a comment to the translators about the use of the string. These are mostly left as nil in the iFolder client.
If you are adding a new file to the project, you'll need to add that file to the src/OSXClient/intlsrcfiles so it becomes part of the i18n process. If you are adding a new .nib file, you'll need to add that file to the /src/OSXClient/intlnibfiles so it's becomes part of the i18n process.
