<gsmarkup> <objects> <window title="This is a test window" closable="no"> <button title="Print Hello!" action="printHello:" target="#NSOwner" /> </window> </objects> </gsmarkup>GNUstep Renaissance automatically knows what attributes require translation, and what do not. For example, the title attribute of both the window and the button requires translation, while the closable attribute, the action and the target attributes, don't.
When GNUstep Renaissance loads the file Window.gsmarkup, it automatically looks for a localized file Window.strings containing translations of all attributes which require translation, and uses the translations if found (please note that the name of the strings file is obtained by replacing the .gsmarkup extension with the .strings extension; in this way, different gsmarkup files automatically use different strings files for translating).
To translate the window, for example, in Italian, all we need to do then is to add a Window.strings file, containing the following code:
"This is a test window" = "Finestra di test"; "Print Hello!" = "Stampa Hello!";(it is recommended that you edit these .strings files in UTF-8 if any characters are non ASCII) and put it in a Italian.lproj subdirectory. This file specified that the string This is a test window has to be translated as Finestra di test, and that Print Hello! has to be translated as Stampa Hello!.
We then add instructions in the GNUmakefile to install this localized file in the application bundle:
include $(GNUSTEP_MAKEFILES)/common.make APP_NAME = Example Example_OBJC_FILES = main.m Example_RESOURCE_FILES = \ Menu-GNUstep.gsmarkup \ Menu-OSX.gsmarkup \ Window.gsmarkup Example_LOCALIZED_RESOURCE_FILES = \ Window.strings Example_LANGUAGES = Italian ifeq ($(FOUNDATION_LIB), apple) ADDITIONAL_INCLUDE_DIRS += -framework Renaissance ADDITIONAL_GUI_LIBS += -framework Renaissance else ADDITIONAL_GUI_LIBS += -lRenaissance endif include $(GNUSTEP_MAKEFILES)/application.make
Now building the program, and running it with the option
openapp ./Example.app -NSLanguages '(Italian)'should display the window in Italian! Please note that GNUstep Renaissance has automatically translated the strings using the appropriate strings file, and then it has automatically sized the interface objects to fit the translated strings - you don't need to do anything special except translating, everything just works (this is not so with gorm and nib files).
If you are using Apple Mac OS X, to run the program in Italian, try changing the language preferences setting Italian as preferred language in the System Preferences, then running the program.