# IupSetLanguage

Definition: | include pGUI.e IupSetLanguage(string language_name)
Description: | Sets the language name used by some pre-defined dialogs. Can also be changed using the global attribute LANGUAGE. language_name: Can have one of the following values: "ENGLISH", "PORTUGUESE", "SPANISH". Default: "ENGLISH". Affects: All elements that have pre-defined texts. The pre-defined texts will be stored using IupSetLanguageString.
pwa/p2js: | Not supported.
Comments: | The native dialogs like IupFileDlg will always be displayed in the system language. Even if the language is not supported (meaning its pack of pre-defined strings are not defined) the new language name will be successfully stored so you can set your own strings and return a coherent value, and the current defined string will not be changed. Here is a list of the pre-defined string names:
    IUP_ERROR
    IUP_ATTENTION (since 3.22)
    IUP_YES
    IUP_NO
    IUP_INVALIDDIR
    IUP_FILEISDIR
    IUP_FILENOTEXIST
    IUP_FILEOVERWRITE
    IUP_CREATEFOLDER
    IUP_NAMENEWFOLDER
    IUP_SAVEAS
    IUP_OPEN
    IUP_SELECTDIR
    IUP_OK
    IUP_CANCEL
    IUP_RETRY
    IUP_APPLY
    IUP_RESET
    IUP_GETCOLOR
    IUP_HELP
    IUP_RED
    IUP_GREEN
    IUP_BLUE
    IUP_HUE
    IUP_SATURATION
    IUP_INTENSITY
    IUP_OPACITY
    IUP_PALETTE
    IUP_TRUE
    IUP_FALSE
    IUP_FAMILY
    IUP_STYLE
    IUP_SIZE
    IUP_SAMPLE
    IUP_ERRORFILEOPEN (since 3.22)
    IUP_ERRORFILESAVE (since 3.22)
Auxiliary Functions: | IupGetLanguage() Returns the language used by some pre-defined dialogs. Returns the same value as the LANGUAGE global attribute. Example:
    IupOpen()
    IupSetLanguage("ENGLISH")
    IupMessage("IUP Language", IupGetLanguage())
    IupClose()
IupSetLanguageString(string name, val) IupStoreLanguageString(string name, val) Associates a name with a string as an auxiliary method for Internationalization of applications. name: name of the string. val: string value. IupStoreLanguageString will duplicate the string internally. IupSetLanguageString will store the pointer. Elements that have pre-defined texts use this function when the current language is changed using IupSetLanguage. IUP will not store strings for several languages at the same time, it will store only for the current language. When IupSetLanguage is called only the internal pre-defined strings are replace in the internal database. The application must register again all its strings for the new language. If a dialog is created with string names associations and the associations are about to be changed, then the dialog must be destroyed before the associations are changed, then created again. Associations are retrieved using the IupGetLanguageString function (see below). But to simplify the usage of the string names associations attributes set with regular IupSetStr* functions can use the prefix "_@" to indicate a string name and not the actual string. IupSetAttribute* functions can not be used because they simply store a pointer that may not be a string. Example:
    // If Language is English
    IupSetLanguageString("IUP_CANCEL", "Cancel")
    //  or
    // If Language is Portuguese
    IupSetLanguageString("IUP_CANCEL", "Cancelar")

    // Then when setting a button title use:
    Ihandle button_cancel = IupButton(IupGetLanguageString("IUP_CANCEL"))
    //  or
    Ihandle button_cancel = IupButton("_@IUP_CANCEL")
    //  or
    IupSetStrAttribute(button_cancel, "TITLE", "_@IUP_CANCEL")
string res = IupGetLanguageString(string name) Returns a language dependent string associated with the name. The string must have been associated with the name using the IupSetLanguageString or IupSetLanguagePack functions. If the association is not found returns the name itself. See example just above. IupSetLanguagePack(Ihandln ih) Sets a pack of associations between names and string values. Internally will call IupSetLanguageString for each name in the pack. ih: pack of name-value association. It is simply an IupUser element with several attributes set. After setting the pack it can be destroyed. The existent associations will not be removed. But if the new ones have the same names, the old ones will be replaced. If set to NULL will remove all current associations. Example:
    Ihandln pack = IupUser()
    IupSetAttribute(pack,"IUP_RED","Vermelho")
    IupSetAttribute(pack,"MY_ITEMCOLORTEST","Teste de Cor")
    IupSetLanguagePack(pack)
    pack = IupDestroy(pack)
Note that pack has an Ihandln type for the benefit of IupDestroy(); IupUser() will throw a (catchable) exception rather than return NULL.
See Also: | IupUser, IupSetAttribute, IupDestroy, LANGUAGE