Skip to content
Snippets Groups Projects
Commit 546db5d1 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Support ctrl/<charset>/text.ini file

For Nelgin's mode7 terminal project
parent 9b53f469
No related branches found
No related tags found
No related merge requests found
Pipeline #8226 passed
// Localized/customized support for JavaScript user-visible text (i.e. strings not contained in text.dat)
// Customized text strings go in the [scriptfilename.js] or [JS] sections of ctrl/text.ini
// Localized (translated to non-default locale) text strings go in the equivalent sections of ctrl/text.<lang>.ini
// Customized text strings go in the [scriptfilename.js] or [JS] sections of ctrl/[charset/]text.ini
// Localized (translated to non-default locale) text strings go in the equivalent sections of ctrl/[charset/]text.<lang>.ini
// For strings that contain control characters,
// an optional 'key' is typically used/specified to look-up those text strings.
......@@ -11,6 +11,9 @@ var gettext_cache = {};
function gettext(orig, key) {
function get_text_from_ini(ini_fname, orig, key){
ini_fname = file_getcase(ini_fname);
if(!ini_fname)
return undefined;
var f = new File(ini_fname);
if(!f.open("r"))
return undefined;
......@@ -24,6 +27,10 @@ function gettext(orig, key) {
return gettext_cache[key || orig];
var text;
if (user.lang)
text = get_text_from_ini(console.charset + "/text." + user.lang + ".ini", orig, key);
if (text === undefined)
text = get_text_from_ini(console.charset + "/text.ini", orig, key);
if (text === undefined && user.lang)
text = get_text_from_ini("text." + user.lang + ".ini", orig, key);
if (text === undefined)
text = get_text_from_ini("text.ini", orig, key);
......
......@@ -111,14 +111,21 @@ void sbbs_t::revert_text(void)
}
/****************************************************************************/
/* Sysops can have custom text based on terminal character set (charset) */
/* Users can have their own language setting, make that current */
/****************************************************************************/
bool sbbs_t::load_user_text(void)
{
char path[MAX_PATH + 1];
revert_text();
safe_snprintf(path, sizeof path, "%s%s/text.ini", cfg.ctrl_dir, term_charset());
if(fexistcase(path))
replace_text(path);
if (*useron.lang == '\0')
return true;
char path[MAX_PATH + 1];
safe_snprintf(path, sizeof path, "%s%s/text.%s.ini", cfg.ctrl_dir, term_charset(), useron.lang);
if(fexistcase(path))
replace_text(path);
safe_snprintf(path, sizeof path, "%stext.%s.ini", cfg.ctrl_dir, useron.lang);
return replace_text(path);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment