Opened 15 years ago

Closed 15 years ago

#224 closed defect (fixed)

Translation: Use default catalog if string not found in plugin catalog

Reported by: Paul Baranowski <paul@…> Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords:


If a string is not found in the plugin language catalog, then we should check the main ("HTMLArea") catalog to see if the string exists there. That way, we arent duplicating strings in the plugin language catalog. Also, this still gives the plugin strings preference in case the plugin needs to override a string in the main language catalog.

Here is the new code for HTMLArea._lc() :

/** Return a localised string.
 * @param string    English language string
 * @param context   Case sensitive context name, eg 'HTMLArea' (default), 'TableOperations'...
HTMLArea._lc = function(string, context)
  if(_editor_lang == "en")
    return string;

  if(typeof HTMLArea._lc_catalog == 'undefined')
    HTMLArea._lc_catalog = [ ];

  if(typeof context == 'undefined')
    context = 'HTMLArea';

  if(typeof HTMLArea._lc_catalog[context] == 'undefined')
    HTMLArea._lc_catalog[context] = HTMLArea._loadlang(context);

  if(typeof HTMLArea._lc_catalog[context][string] == 'undefined')
  	// If we are looking at a plugin language file,
  	// we now check to see if the string is in the
  	// main translation file so as not to duplicate translation strings. 
  	if (context != 'HTMLArea') {
  		// Load the main language file if it isnt loaded already.
		if(typeof HTMLArea._lc_catalog['HTMLArea'] == 'undefined')
		  HTMLArea._lc_catalog['HTMLArea'] = HTMLArea._loadlang('HTMLArea');
  		// Look for the string in the main language file
		if(typeof HTMLArea._lc_catalog['HTMLArea'][string] != 'undefined') 
		  return HTMLArea._lc_catalog['HTMLArea'][string];
    return string; // Indicate it's untranslated
    return HTMLArea._lc_catalog[context][string];

Change History (1)

comment:1 Changed 15 years ago by niko

  • Resolution set to fixed
  • Status changed from new to closed

sounds great for me!
so we don't have a separate translation for OK and Cancel for every plugin!

changeset:108 (a bit different from your code, but the concept is yours :D)

Note: See TracTickets for help on using tickets.