Commit 27c9bb37 authored by Claes Sjofors's avatar Claes Sjofors

Language codes added

parent 0ca7c2c9
......@@ -127,4 +127,6 @@
091111 cs gdh Bugfix in nethandler SetObjectInfo and GetObjectInfo.
091209 cs co Command line interpreter, command not converted to upper case any more.
091211 cs rtt rt_rtt runable on sev station to show qcom nodes and qcom applications.
091211 cs pwre Format of pwre database changed. Delimiter character changed from : to ;.
100111 cs pwrb Attribute (and method) Photo added to signal objects.
100111 cs co Set language is prepared for all languages and checks if language is installed.
\ No newline at end of file
......@@ -24,12 +24,149 @@
#include "pwr.h"
extern "C" {
#include "co_dcli.h"
}
#include "co_cdh.h"
#include "co_lng.h"
lng_eLanguage Lng::lang = lng_eLanguage_en_us;
// Note, this is matched with lng_eLanguage
static char lng_cLanguageStr[lng_eLanguage__][6] = {
"",
"af_ZA",
"ar_AE",
"ar_BH",
"ar_DZ",
"ar_EG",
"ar_IN",
"ar_IQ",
"ar_JO",
"ar_KW",
"ar_LB",
"ar_LY",
"ar_MA",
"ar_OM",
"ar_QA",
"ar_SA",
"ar_SD",
"ar_SY",
"ar_TN",
"ar_YE",
"be_BY",
"bg_BG",
"br_FR",
"bs_BA",
"ca_ES",
"cs_CZ",
"cy_GB",
"da_DK",
"de_AT",
"de_BE",
"de_CH",
"de_DE",
"de_LU",
"el_GR",
"en_AU",
"en_BW",
"en_CA",
"en_DK",
"en_GB",
"en_HK",
"en_IE",
"en_IN",
"en_NZ",
"en_PH",
"en_SG",
"en_US",
"en_ZA",
"en_ZW",
"es_AR",
"es_BO",
"es_CL",
"es_CO",
"es_CR",
"es_DO",
"es_EC",
"es_ES",
"es_GT",
"es_HN",
"es_MX",
"es_NI",
"es_PA",
"es_PE",
"es_PR",
"es_PY",
"es_SV",
"es_US",
"es_UY",
"es_VE",
"et_EE",
"eu_ES",
"fa_IR",
"fi_FI",
"fo_FO",
"fr_BE",
"fr_CA",
"fr_CH",
"fr_FR",
"fr_LU",
"ga_IE",
"gl_ES",
"gv_GB",
"he_IL",
"hi_IN",
"hr_HR",
"hu_HU",
"id_ID",
"is_IS",
"it_CH",
"it_IT",
"iw_IL",
"ja_JP",
"ka_GE",
"kl_GL",
"ko_KR",
"kw_GB",
"lt_LT",
"lv_LV",
"mi_NZ",
"mk_MK",
"mr_IN",
"ms_MY",
"mt_MT",
"nl_BE",
"nl_NL",
"nn_NO",
"no_NO",
"oc_FR",
"pl_PL",
"pt_BR",
"pt_PT",
"ro_RO",
"ru_RU",
"ru_UA",
"se_NO",
"sk_SK",
"sl_SI",
"sq_AL",
"sr_YU",
"sv_FI",
"sv_SE",
"ta_IN",
"te_IN",
"tg_TJ",
"th_TH",
"tl_PH",
"tr_TR",
"uk_UA",
"ur_PK",
"uz_UZ",
"vi_VN",
"wa_BE",
"yi_US",
"zh_CN",
"zh_HK",
"zh_TW"};
lng_eLanguage Lng::lang = lng_eLanguage_en_US;
tree_sTable *Lng::tree = 0;
char *Lng::get_language_str()
......@@ -39,55 +176,38 @@ char *Lng::get_language_str()
lng_eLanguage Lng::str_to_lang( char *str)
{
if ( strcmp( str, "en_us") == 0)
return lng_eLanguage_en_us;
if ( strcmp( str, "sv_se") == 0)
return lng_eLanguage_sv_se;
if ( strcmp( str, "de_de") == 0)
return lng_eLanguage_de_de;
if ( strcmp( str, "fr_fr") == 0)
return lng_eLanguage_fr_fr;
for ( int i = 1; i < lng_eLanguage__; i++) {
if ( cdh_NoCaseStrcmp( lng_cLanguageStr[i], str) == 0)
return (lng_eLanguage) i;
}
// Not found
return lng_eLanguage_;
}
// Convert language enum to lower case string
char *Lng::lang_to_str( lng_eLanguage language)
{
static char result[20];
switch( language) {
case lng_eLanguage_sv_se:
strcpy( result, "sv_se");
break;
case lng_eLanguage_de_de:
strcpy( result, "de_de");
break;
case lng_eLanguage_fr_fr:
strcpy( result, "fr_fr");
break;
default:
strcpy( result, "en_us");
}
if ( language >= lng_eLanguage__ || language <= 0)
strcpy( result, "");
else
strcpy( result, cdh_Low( lng_cLanguageStr[language]));
return result;
}
// Convert language enum to string
char *Lng::lang_to_locale( lng_eLanguage language)
{
static char result[20];
switch( language) {
case lng_eLanguage_sv_se:
strcpy( result, "sv_SE");
break;
case lng_eLanguage_de_de:
strcpy( result, "de_DE");
break;
case lng_eLanguage_fr_fr:
strcpy( result, "fr_FR");
break;
default:
strcpy( result, "en_US");
}
if ( language >= lng_eLanguage__ || language <= 0)
strcpy( result, "");
else
strcpy( result, lng_cLanguageStr[language]);
return result;
}
......@@ -119,7 +239,7 @@ char *Lng::translate( const char *text)
int sts;
char *in_p;
if ( lang == lng_eLanguage_en_us || tree == 0) {
if ( lang == lng_eLanguage_en_US || tree == 0) {
// No translation is needed
strncpy( result, text, sizeof(result));
result[sizeof(result)-1] = 0;
......@@ -171,7 +291,7 @@ int Lng::translate( char *text, char *out)
int sts;
char *in_p;
if ( lang == lng_eLanguage_en_us || tree == 0) {
if ( lang == lng_eLanguage_en_US || tree == 0) {
// No translation is needed
return 0;
}
......@@ -381,28 +501,53 @@ void Lng::get_uid( char *in, char *out)
void Lng::set( char *language)
{
lng_eLanguage l = str_to_lang( language);
if ( l != lng_eLanguage_)
set( l);
pwr_tStatus sts;
lng_eLanguage l = str_to_lang( language);
if ( l != lng_eLanguage_) {
sts = set( l);
if ( EVEN(sts)) return;
}
setlocale( LC_ALL, lang_to_locale( l));
}
void Lng::set( lng_eLanguage language)
pwr_tStatus Lng::set( lng_eLanguage language)
{
if ( lang == language)
return;
return 1;
if ( language == lng_eLanguage_en_US) {
lang = language;
if ( lang == lng_eLanguage_en_us)
unload();
else
}
else {
if ( !is_installed( language))
return 0;
lang = language;
read();
}
setlocale( LC_ALL, lang_to_locale( lang));
return 1;
}
bool Lng::is_installed( lng_eLanguage language)
{
pwr_tFileName fname;
pwr_tFileName found_file;
pwr_tStatus sts;
strcpy( fname, "$pwr_exe/");
strcat( fname, lang_to_str( language));
strcat( fname, "/xtt_lng.dat");
dcli_translate_filename( fname, fname);
sts = dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_INIT);
dcli_search_file( fname, found_file, DCLI_DIR_SEARCH_END);
if ( ODD(sts)) return true;
return false;
}
......
......@@ -42,10 +42,141 @@ extern "C" {
typedef enum {
lng_eLanguage_,
lng_eLanguage_en_us,
lng_eLanguage_sv_se,
lng_eLanguage_de_de,
lng_eLanguage_fr_fr
lng_eLanguage_af_ZA,
lng_eLanguage_ar_AE,
lng_eLanguage_ar_BH,
lng_eLanguage_ar_DZ,
lng_eLanguage_ar_EG,
lng_eLanguage_ar_IN,
lng_eLanguage_ar_IQ,
lng_eLanguage_ar_JO,
lng_eLanguage_ar_KW,
lng_eLanguage_ar_LB,
lng_eLanguage_ar_LY,
lng_eLanguage_ar_MA,
lng_eLanguage_ar_OM,
lng_eLanguage_ar_QA,
lng_eLanguage_ar_SA,
lng_eLanguage_ar_SD,
lng_eLanguage_ar_SY,
lng_eLanguage_ar_TN,
lng_eLanguage_ar_YE,
lng_eLanguage_be_BY,
lng_eLanguage_bg_BG,
lng_eLanguage_br_FR,
lng_eLanguage_bs_BA,
lng_eLanguage_ca_ES,
lng_eLanguage_cs_CZ,
lng_eLanguage_cy_GB,
lng_eLanguage_da_DK,
lng_eLanguage_de_AT,
lng_eLanguage_de_BE,
lng_eLanguage_de_CH,
lng_eLanguage_de_DE,
lng_eLanguage_de_LU,
lng_eLanguage_el_GR,
lng_eLanguage_en_AU,
lng_eLanguage_en_BW,
lng_eLanguage_en_CA,
lng_eLanguage_en_DK,
lng_eLanguage_en_GB,
lng_eLanguage_en_HK,
lng_eLanguage_en_IE,
lng_eLanguage_en_IN,
lng_eLanguage_en_NZ,
lng_eLanguage_en_PH,
lng_eLanguage_en_SG,
lng_eLanguage_en_US,
lng_eLanguage_en_ZA,
lng_eLanguage_en_ZW,
lng_eLanguage_es_AR,
lng_eLanguage_es_BO,
lng_eLanguage_es_CL,
lng_eLanguage_es_CO,
lng_eLanguage_es_CR,
lng_eLanguage_es_DO,
lng_eLanguage_es_EC,
lng_eLanguage_es_ES,
lng_eLanguage_es_GT,
lng_eLanguage_es_HN,
lng_eLanguage_es_MX,
lng_eLanguage_es_NI,
lng_eLanguage_es_PA,
lng_eLanguage_es_PE,
lng_eLanguage_es_PR,
lng_eLanguage_es_PY,
lng_eLanguage_es_SV,
lng_eLanguage_es_US,
lng_eLanguage_es_UY,
lng_eLanguage_es_VE,
lng_eLanguage_et_EE,
lng_eLanguage_eu_ES,
lng_eLanguage_fa_IR,
lng_eLanguage_fi_FI,
lng_eLanguage_fo_FO,
lng_eLanguage_fr_BE,
lng_eLanguage_fr_CA,
lng_eLanguage_fr_CH,
lng_eLanguage_fr_FR,
lng_eLanguage_fr_LU,
lng_eLanguage_ga_IE,
lng_eLanguage_gl_ES,
lng_eLanguage_gv_GB,
lng_eLanguage_he_IL,
lng_eLanguage_hi_IN,
lng_eLanguage_hr_HR,
lng_eLanguage_hu_HU,
lng_eLanguage_id_ID,
lng_eLanguage_is_IS,
lng_eLanguage_it_CH,
lng_eLanguage_it_IT,
lng_eLanguage_iw_IL,
lng_eLanguage_ja_JP,
lng_eLanguage_ka_GE,
lng_eLanguage_kl_GL,
lng_eLanguage_ko_KR,
lng_eLanguage_kw_GB,
lng_eLanguage_lt_LT,
lng_eLanguage_lv_LV,
lng_eLanguage_mi_NZ,
lng_eLanguage_mk_MK,
lng_eLanguage_mr_IN,
lng_eLanguage_ms_MY,
lng_eLanguage_mt_MT,
lng_eLanguage_nl_BE,
lng_eLanguage_nl_NL,
lng_eLanguage_nn_NO,
lng_eLanguage_no_NO,
lng_eLanguage_oc_FR,
lng_eLanguage_pl_PL,
lng_eLanguage_pt_BR,
lng_eLanguage_pt_PT,
lng_eLanguage_ro_RO,
lng_eLanguage_ru_RU,
lng_eLanguage_ru_UA,
lng_eLanguage_se_NO,
lng_eLanguage_sk_SK,
lng_eLanguage_sl_SI,
lng_eLanguage_sq_AL,
lng_eLanguage_sr_YU,
lng_eLanguage_sv_FI,
lng_eLanguage_sv_SE,
lng_eLanguage_ta_IN,
lng_eLanguage_te_IN,
lng_eLanguage_tg_TJ,
lng_eLanguage_th_TH,
lng_eLanguage_tl_PH,
lng_eLanguage_tr_TR,
lng_eLanguage_uk_UA,
lng_eLanguage_ur_PK,
lng_eLanguage_uz_UZ,
lng_eLanguage_vi_VN,
lng_eLanguage_wa_BE,
lng_eLanguage_yi_US,
lng_eLanguage_zh_CN,
lng_eLanguage_zh_HK,
lng_eLanguage_zh_TW,
lng_eLanguage__
} lng_eLanguage;
typedef struct {
......@@ -129,7 +260,7 @@ class Lng {
static char *get_language_str();
static int translate( char *in, char *out);
static void unload();
static void set( lng_eLanguage language);
static pwr_tStatus set( lng_eLanguage language);
static lng_eLanguage current() { return lang;}
static void set( char *language);
static char *get( int item)
......@@ -140,6 +271,7 @@ class Lng {
static lng_eLanguage str_to_lang( char *str);
static char *lang_to_str( lng_eLanguage language);
static char *lang_to_locale( lng_eLanguage language);
static bool is_installed( lng_eLanguage language);
};
#if defined __cplusplus
......
......@@ -58,7 +58,7 @@ int xnav_open_URL( pwr_tURL url)
if ( strncmp( url, "$pwr_lang/", 10) == 0) {
// If file in $pwr_lang, check if file exist, else take en_us
if ( Lng::current() != lng_eLanguage_en_us) {
if ( Lng::current() != lng_eLanguage_en_US) {
pwr_tURL testurl;
pwr_tTime t;
......
<TOPIC> overview
<image> pwr_logga.gif
<h1>Overview
<b>Project Help <link> index,,$pwrp_exe/xtt_help.dat
<b>Operator's Guide <link> index,,$pwr_exe/en_us/man_opg.dat
<b>Classes <link> classes
<b>Index <index>
</TOPIC>
<TOPIC> classes
Classes
<B>SystemClasses <LINK>pwrs, ,$pwr_exe/en_us/pwrs_xtthelp.dat
<B>BaseClasses <LINK>pwrb, ,$pwr_exe/en_us/pwrb_xtthelp.dat
<B>BaseComponent <LINK>basecomponent, ,$pwr_exe/en_us/basecomponent_xtthelp.dat
<B>NMps <LINK>nmps, ,$pwr_exe/en_us/nmps_xtthelp.dat
<B>Profibus <LINK>profibus, ,$pwr_exe/en_us/profibus_xtthelp.dat
<B>Opc <LINK>opc, ,$pwr_exe/en_us/opc_xtthelp.dat
<B>OtherIO <LINK>otherio, ,$pwr_exe/en_us/otherio_xtthelp.dat
<B>SsabOx <LINK>ssabox, ,$pwr_exe/en_us/ssabox_xtthelp.dat
<B>OtherManufacturer <LINK>othermanufacturer, ,$pwr_exe/en_us/othermanufacturer_xtthelp.dat
<B>ABB <LINK>abb, ,$pwr_exe/en_us/abb_xtthelp.dat
<B>Siemens <LINK>siemens, ,$pwr_exe/en_us/siemens_xtthelp.dat
</TOPIC>
<include> $pwr_exe/en_us/pwrs_xtthelp.dat
<include> $pwr_exe/en_us/pwrb_xtthelp.dat
<include> $pwr_exe/en_us/basecomponent_xtthelp.dat
<include> $pwr_exe/en_us/nmps_xtthelp.dat
<include> $pwr_exe/en_us/profibus_xtthelp.dat
<include> $pwr_exe/en_us/opc_xtthelp.dat
<include> $pwr_exe/en_us/ssabox_xtthelp.dat
<include> $pwr_exe/en_us/otherio_xtthelp.dat
<include> $pwr_exe/en_us/othermanufacturer_xtthelp.dat
<include> $pwr_exe/en_us/abb_xtthelp.dat
<include> $pwr_exe/en_us/siemens_xtthelp.dat
<include> $pwr_exe/en_us/man_opg.dat
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment