The basic principles #fH1:The basic principles #SpriteFile Pictures.Principles #Sprite c,f colorlogo #line All language dependant parts of applications like resources_structure> file and resources_structure> file are stored in directories named like their respective countries, all stored in the resources_structure> directory. Other files like resources_structure> files or resources_structure> files could also could be part of them. All countries RISC OS knows of are supported. The CLI command {fCode}*Countries{f} shows a list in which most countries of (West-)Europe can be found. It is important to stick to the spelling RISC OS uses. The directory for Germany is thus called {f15}Germany{f} and not Deutschland (this is the German translation for Germany). Such a country directory takes care of the whole translation business. All translations are stored inside the directory {f15}Resources{f}, which resides inside the application. All non language dependant resources reside directly inside the application, as usual, that is to say they do not have to be put in several language directories. A typical application called {f15}!App{f} supporting {f15}ResFind{f} is as follows: #Sprite c,f structure In this case the application {f15}!App{f} is designed to support German, Dutch and English languages. At least the language {f15}UK{f}, that is English, has to be there since {f15}ResFind{f} reverts to this one in case the application does not support any language fitting better. When {f15}ResFind{f} is run, it looks for translations (that is language directories) along the following list of languages: #indent +8 - {fCode}\{f}, where {f15}App{f} is the name of the application. For {f15}!ResConf{f} this variable would be {fCode}ResConf$Language{f} and is set by the application itself. - {fCode}\{f}, a global system variable containing the list of preferred languages, preferred to the one the computer is configured to, that is to say the "Configured Language" set by the system when booting. - {fCode}\{f}, again a global system variable, this time containing the list of languages the user would rather have instead of the English (UK) language. #indent The system variables: {fCode}ResFind$LanguagesPref{f} and {fCode}ResFind$LanguagesSuff{f} are set by the application {f15}ResConf{f} and stored in the the obey file {f15}SetResVars{f} located in {f15}!Boot.Resources.!ResFind{f} to be initialised each time the system is booted. They can be changed by running {f15}ResConf{f}. If none of them have been set, this list is reduced to the "Configured Language" and the English language (UK). This makes life quite nice for the user and makes sure that the application runs in the "Configured Language" or English language, something most users can live with. #indent;line;align centre {f15}ResFind package documentation{f} What the programmer has to do #fH1:General principles #SpriteFile Pictures.Logos #Sprite c,f colorlogo #line {f15}ResFind{f} typically called in the {f15}!Run{f} obey file will search for the proper language dependent resources in the {f15}Resources{f} directory assuming that this one provides language sub-directories such as {f15}UK{f}, {f15}Germany{f}, {f15}France{f}, etc .. namely all the country names language of which the user want to support in his software. To access a single directory the use of a path variable is not necessary. {f15}ResFind{f} sets a path variable which points to the language directory and to the application directory as well. So you can store the language independent resources inside the application once instead of once in each language directory. During the development of the application all resources can even be put inside the application not worrying about language directories at that time. Creation of the resources directory structure need not be made until just before releasing the application. The application has to be developed in a way that the program can be translated without the need to alter the source code. Acorn made sure that this is possible. The most important thing to to is to put all messages into the resources_structure> file, which can (and should) be loaded and read using the {f15}MessageTrans{f} module. References to messages in the application are then done using the so called message tags. Doing so is not new and will not be expained any further here. As for resources_structure> they can be either language dependent or independent. #line;align centre {f15}ResFind package documentation{f} What the programmer has to do #fH1:Using ResFind in !Help obey file #SpriteFile Pictures.Logos #Sprite c,f colorlogo #line Assuming that some language dependent {f15}Help{f} text is stored in language directories such text can be displayed by using {f15}ResFind{f} and the command {fCode}Filer_Run ...{f}. In this case the {f15}!Help{f} obey file could look like this: #indent 8 {fCode}| !Help File for !App Set App$Dir \ Set Dummy$Path \.Resources.,\ Run Dummy:ResFind App Unset Dummy$Path Filer_Run AppRes:Help{f} #indent Please note that the {fCode}Filer_Run...{f} command is not available in RISC OS 2 so that a utility or module featuring it has to be loaded first. #indent;line;align centre {f15}ResFind package documentation{f}What the programmer has to do #SpriteFile Pictures.Logos #fH1:!RunImage code interface #Sprite c,f colorlogo #line The resources have to be accessed using the path variable set by {f15}ResFind{f}. #indent 8 * In BASIC that would be done like this assuming that the application name is {f15}!App{f}: {fCode}SYS "MessageTrans_OpenFile",file%,"AppRes:Messages" SYS "Wimp_OpenTemplate",,"AppRes:Templates"{f} Note: the GAG-Libraries use the correct path variable automatically. With most C libraries the path variable can be used easily as well. E.g. for DeskLib all to do is to code: {fCode}strcpy(resource_pathname,"AppRes:"){f} This must be achieved prior to loading any resources. That is all to do as for program coding to support {f15}ResFind{f} #indent;line;align centre {f15}ResFind package documentation{f}What the programmer has to do #fH1:Using ResFind and ResError in !Run obey file #SpriteFile Pictures.Logos #Sprite c,f colorlogo #line Let us consider an application called !App. In its {f15}!Run{f} file, {f15}ResFind{f} has to be called to set the path variable. A typical {f15}!Run{f} file looks like this: #indent 8 {fCode}| !Run File for !App | Set App$Dir \ IconSprites \.!Sprites Set Dummy$Path \.Resources.,\ Run Dummy:ResFind App RMEnsure Module 3.50 Run Dummy:ResError App RPC Unset Dummy$Path | Wimpslot 64k 64k Run \.!RunImage{f} * The system variable {fCode}Dummy$Path{f} is just used as a path to locate the Basic application {f15}ResFind{f} to be run. Ii is unset after being used. * The command line: {fCode}Dummy:ResFind App{f} defines a system variable {fCode}AppRes$Path{f} which contains the path to the language directory. For example for an application called {f15}!Vorbild{f} the command line would be {fCode}Dummy:ResFind Vorbild{f}. * The command line: {fCode}Run Dummy:ResError App RPC{f} is used to display a language dependant message text in an error box. This message is to be sought in the {f15}AppRes:Messages{f} file with the message tag "RPC" (here). Due to this {f15}ResError{f} cannot be called if the {f15}MesssageTrans{f} module has not been loaded beforehand (only of importance with RISC OS 2). Furthermore {f15}ResError{f} looks for the message tag "RESERR" which it will use for the title of the error box. If this tag is not in the {f15}AppRes:Messages{f} file the default "Hint from {f15}ResError{f}" will be used. {f15}ResError{f} could possibly be used in {f15}!Boot{f} file as well. #indent;line;align centre {f15}ResFind package documentation{f}What the programmer has to do #fH1:Using ResFind in !Boot obey file #SpriteFile Pictures.Logos #Sprite c,f colorlogo #line Assuming that some language dependent {f15}!Sprites{f}, {f15}!Sprites22{f}, and {f15}!Sprites23{f} sprite files are stored in language directories of an application called {f15}!App{f} such files can be loaded by using {f15}ResFind{f} and the command {fCode}IconSprites ...{f}. In this case the {f15}!Boot{f} obey file could look like this: #indent 8 {fCode}| !Boot File for !App Set App$Dir \ Set Dummy$Path \.Resources.,\ Run Dummy:ResFind App Unset Dummy$Path IconSprites AppRes:!Sprites{f} #indent;line;align centre {f15}ResFind package documentation{f}