Translate Output Language

This allows the Default Output Language (Tools > Preferences > International > Default Output Language ) to be determined, and the associated Language Pack used to translate words and phrases into that language.

The Language Pack Miscellaneous Translation Table may need editing by the user to add the required words and phrases (see ‘Supplying all necessary translations for language pack translation tables’ in How to Create a Language Pack.) It would be useful to include instructions (and the words that need to be translated) in the plugin’s help.

The translated text can be applied to published documents in a similar way to Reports, and that is most relevant to Report type plugins and plugins that manage web pages.

Requires: Registry Key Read

g_trans_misc = { Output_Language = ""; }	-- Create global Language Pack translation table
if fhGetAppVersion() > 6 then
  local strLang = getRegKey("HKCU\\SOFTWARE\\Calico Pie\\Family Historian\\2.0\\Preferences\\Output Language Id")
  if #strLang > 2 then		-- Load the miscellaneous translations for chosen Language Pack
    local strPack = fhGetContextInfo("CI_APP_DATA_FOLDER").."\\Lang\\"..strLang.."\\lang_trans_misc.fh_lua"
    dofile(strPack)
    g_trans_misc.Output_Language = " for Output Language "..strLang
  else
    g_trans_misc.Output_Language = " for English"
  end
end

function StrTranslate(strText)	-- Translate text to current output language 
    return g_trans_misc["~CASE:"..strText] or g_trans_misc[strText] or strText
end -- function StrTranslate

Usage

Note that g_trans_misc.Output_Language can be used in messages to the user.

Text in the plugin is translated by calling StrTranslate(“any text”) that returns the translation, or the original text when no translation is available. If necessary, a special CASE can be employed to distinguish different translations.