Example #1
0
 def _test_loadcatalog(self, code):
     success=True
     try:
         i18n.set_language(code)
     except IOError:
         success=False
     return success
Example #2
0
 def login(self, connection, account):
     i18n.set_language(connection, account.language)
     if not connection.web:
         connection.encode_args = (account.encoding, 'replace')
         connection.decode_args = (account.encoding, 'ignore')
     if account.name.lower() in game.players:
         old_con = game.players[account.name.lower()]
         connection.notify(connection._("Disconnecting old connection."))
         game.server.connections.remove(old_con)
         game.server.on_disconnect(gsb.Caller(connection=old_con))
         game.server.disconnect(old_con)
     connection.account = account
     connection.nickname = account.name
     connection.parser = parser
     connection.is_admin = account.is_admin
     account.last_logged_in = func.now()
     for i in account.ignores:
         connection.ignores.add(i.ignored_account.name)
     connection.session.commit()
     for pl in game.players.values():
         pl.notify(pl._("%s logged in.") % connection.nickname)
     game.players[connection.nickname.lower()] = connection
     motd_file = os.path.join('locale', connection.language, 'motd.txt')
     if not os.path.exists(motd_file):
         motd_file = os.path.join('locale', 'en', 'motd.txt')
     if os.path.exists(motd_file):
         with open(motd_file, 'r') as fp:
             connection.notify(fp.read())
Example #3
0
 def __init__(self, config=None):
      """Using the given config file, opens the database at initialisation time"""
      if not config: # if no config object given, use the default config file
          config=configfile.read_config()
      self.config=config
      self.db = sqlite.connect(config['global']['database'])
      self.version=version #version, the module
      i18n.set_language(config['global']['language'])
      self._schemas_cache={} # A schema cache, to keep one instance in memory
      self._userbase_cache={} # A userbase cache. XXX TODO : USE A FIFO HERE FOR MEMORY SAVE
Example #4
0
def setup_localization(environ: Dict[str, Any]) -> str:
    """Provides localized strings for this thread."""
    # Set up localization.
    languages = environ.get("HTTP_ACCEPT_LANGUAGE")
    if languages:
        parsed = accept_language.parse_accept_language(languages)
        if parsed:
            language = parsed[0].language
            i18n.set_language(language)
            return cast(str, language)
    return ""
Example #5
0
    def __init__(self, args):
        super().__init__(args)

        logger.info("Starting application")

        language = Configuration().settings_language()
        i18n.set_language(language)

        self.main_window = RsMainWindow()

        self.aboutToQuit.connect(self.__before_close__)

        sys.exit(self.exec_())
Example #6
0
    def __init__(self, args):
        super().__init__(args)

        logger.info("Starting application")

        language = Configuration().settings_language()
        i18n.set_language(language)

        self.main_window = RsMainWindow()

        self.aboutToQuit.connect(self.__before_close__)

        sys.exit(self.exec_())
Example #7
0
def update_missing_housenumbers(relations: areas.Relations,
                                update: bool) -> None:
    """Update the relation's house number coverage stats."""
    info("update_missing_housenumbers: start")
    for relation_name in relations.get_active_names():
        relation = relations.get_relation(relation_name)
        if not update and os.path.exists(
                relation.get_files().get_housenumbers_percent_path()):
            continue
        streets = relation.get_config().should_check_missing_streets()
        if streets == "only":
            continue

        orig_language = i18n.get_language()
        relation.write_missing_housenumbers()
        for language in ["en", "hu"]:
            i18n.set_language(language)
            cache.get_missing_housenumbers_html(relation)
        i18n.set_language(orig_language)
    info("update_missing_housenumbers: end")
Example #8
0
 def __exit__(self, _exc_type: Any, _exc_value: Any,
              _exc_traceback: Any) -> bool:
     """Switches back to the old language."""
     i18n.set_language("en")
     return True
Example #9
0
 def __enter__(self) -> 'LanguageContext':
     """Switches to the new language."""
     i18n.set_language(self.language)
     return self
Example #10
0
import g
import sys
import dirs

# Manually "pre-parse" command line arguments for -s|--singledir and --multidir,
# so g.get_save_folder reports the correct location of preferences file
for parser in sys.argv[1:]:
    if parser == "--singledir" or parser == "-s": g.force_single_dir = True
    if parser == "--multidir": g.force_single_dir = False

# Create all directories first
dirs.create_directories(g.force_single_dir)

# Set language second, so help page and all error messages can be translated
import i18n
i18n.set_language(force=True)

langs = i18n.available_languages()
language = i18n.language

# Since we require numpy anyway, we might as well ask pygame to use it.
try:
    import pygame
    pygame.surfarray.use_arraytype("numpy")
except AttributeError:
    pass  # Pygame older than 1.8.
except ValueError:
    raise SystemExit("Endgame: Singularity requires NumPy.")
except ImportError:
    raise SystemExit("Endgame: Singularity requires pygame.")
Example #11
0
import g
import sys
import dirs

# Manually "pre-parse" command line arguments for -s|--singledir and --multidir,
# so g.get_save_folder reports the correct location of preferences file
for parser in sys.argv[1:]:
    if parser == "--singledir" or parser == "-s": g.force_single_dir = True
    if parser == "--multidir"                   : g.force_single_dir = False

# Create all directories first
dirs.create_directories(g.force_single_dir)

# Set language second, so help page and all error messages can be translated
import i18n
i18n.set_language(force=True)

langs = i18n.available_languages()
language = i18n.language

# Since we require numpy anyway, we might as well ask pygame to use it.
try:
    import pygame
    pygame.surfarray.use_arraytype("numpy")
except AttributeError:
    pass # Pygame older than 1.8.
except ValueError:
    raise SystemExit("Endgame: Singularity requires NumPy.")
except ImportError:
    raise SystemExit("Endgame: Singularity requires pygame.")