Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uber/configspec.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dev_box = boolean(default=True)
plugins = string_list(default=list())

# Sets the fallback locale in case a translation can't be found.
default_locale = string(default="en_US")
default_locale = string(default="en-US")

# List of directories we should look in for our templates
# This list is appended to by plugins, we'll look for a template
Expand Down
2 changes: 1 addition & 1 deletion uber/custom_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,4 +864,4 @@ def javascript_bool(val):

@JinjaEnv.jinja_export
def l10n(key: str) -> str:
return L10n.translation('en-US').format_value(key)
return L10n.translation(c.DEFAULT_LOCALE).format_value(key)
3 changes: 2 additions & 1 deletion uber/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from wtforms.utils import unset_value
from wtforms.validators import StopValidation, ValidationError

from uber.config import c
from uber.forms.widgets import (
DateMaskInput, IntSelect, MultiCheckbox, Ranking, SelectButtonGroup,
SwitchInput, UniqueList
Expand Down Expand Up @@ -531,7 +532,7 @@ def wrap_formdata(self, form, formdata):
return super().wrap_formdata(form, formdata)

def get_translations(self, _):
return L10n.gettext('en-US')
return L10n.gettext(c.DEFAULT_LOCALE)


class AddressForm(MagForm):
Expand Down
7 changes: 1 addition & 6 deletions uber/l10n.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from fluent.runtime import FluentLocalization, FluentResourceLoader
from itertools import chain
from os import listdir
from pathlib import PurePath
from typing import ClassVar

from uber.config import c
Expand Down Expand Up @@ -32,17 +31,13 @@ def load_l10ns(cls, plugin_dir: str) -> None:
cls.__loader = FluentResourceLoader([
f'{dir}/{{locale}}' for dir in cls.__plugin_dirs
])
plugin_locales = [
filter(lambda file: not PurePath(file).suffix, listdir(dir))
for dir in cls.__plugin_dirs
]
cls.__translations = {
locale: FluentLocalization(
[locale] +
([c.DEFAULT_LOCALE] if locale != c.DEFAULT_LOCALE else []),
['main.ftl'], cls.__loader
)
for locale in set(chain(*plugin_locales))
for locale in set(chain(*map(listdir, cls.__plugin_dirs)))
}
cls.__gettext = {
key: FluentGettext(value)
Expand Down
File renamed without changes.
Loading