def update_jsi18n_file(code='en'):
 translation.activate(code)
 output_dir = os.path.join(settings.CONTENT_ROOT, 'locale', 'js', 'i18n')
 ensure_dir(output_dir)
 output_file = os.path.join(output_dir, ('%s.js' % code))
 request = HttpRequest()
 request.path = output_file
 request.session = {settings.LANGUAGE_COOKIE_NAME: code}
 response = javascript_catalog(request, packages=('ka-lite.locale',), domain='djangojs')
 icu_js = ''
 for path in settings.LOCALE_PATHS:
  try:
   icu_js = open(os.path.join(path, code, ('%s_icu.js' % code)), 'r').read()
  except IOError:
   logging.warn('No {code}_icu.js file found in locale_path {path}'.format(code=code, path=path))
 output_js = ((response.content + '\n') + icu_js)
 logging.info('Writing i18nized js file to {0}'.format(output_file))
 with open(output_file, 'w') as fp:
  fp.write(output_js)
 translation.deactivate()

def update_jsi18n_file ( code = 'en' ) : translation . activate ( code ) output_dir = os . path . join ( settings . CONTENT_ROOT , 'locale' , 'js' , 'i18n' ) ensure_dir ( output_dir ) output_file = os . path . join ( output_dir , ( '%s.js' % code ) ) request = HttpRequest ( ) request . path = output_file request . session = { settings . LANGUAGE_COOKIE_NAME : code } response = javascript_catalog ( request , packages = ( 'ka-lite.locale' , ) , domain = 'djangojs' ) icu_js = '' for path in settings . LOCALE_PATHS : try : icu_js = open ( os . path . join ( path , code , ( '%s_icu.js' % code ) ) , 'r' ) . read ( ) except IOError : logging . warn ( 'No {code}_icu.js file found in locale_path {path}' . format ( code = code , path = path ) ) output_js = ( ( response . content + '\n' ) + icu_js ) logging . info ( 'Writing i18nized js file to {0}' . format ( output_file ) ) with open ( output_file , 'w' ) as fp : fp . write ( output_js ) translation . deactivate ( )
for efficienys sake .