def load_strings(helpers, default='en'):
 global strings
 p = helpers.get_platform()
 locale_dir = helpers.get_resource_path('locale')
 translations = {}
 for filename in os.listdir(locale_dir):
  abs_filename = os.path.join(locale_dir, filename)
  (lang, ext) = os.path.splitext(filename)
  if abs_filename.endswith('.json'):
   lang_json = open(abs_filename, encoding='utf-8').read()
   translations[lang] = json.loads(lang_json)
 strings = translations[default]
 (lc, enc) = locale.getdefaultlocale()
 if lc:
  lang = lc[:2]
  if (lang in translations):
   for key in translations[default]:
    if (key in translations[lang]):
     strings[key] = translations[lang][key]

def load_strings ( helpers , default = 'en' ) : global strings p = helpers . get_platform ( ) locale_dir = helpers . get_resource_path ( 'locale' ) translations = { } for filename in os . listdir ( locale_dir ) : abs_filename = os . path . join ( locale_dir , filename ) ( lang , ext ) = os . path . splitext ( filename ) if abs_filename . endswith ( '.json' ) : lang_json = open ( abs_filename , encoding = 'utf-8' ) . read ( ) translations [ lang ] = json . loads ( lang_json ) strings = translations [ default ] ( lc , enc ) = locale . getdefaultlocale ( ) if lc : lang = lc [ : 2 ] if ( lang in translations ) : for key in translations [ default ] : if ( key in translations [ lang ] ) : strings [ key ] = translations [ lang ] [ key ]
loads translated strings and fallback to english if the translation does not exist .