Skip to content

Commit

Permalink
Enable Fluent string replacement for Pocket About page
Browse files Browse the repository at this point in the history
Note how we get the brands.ftl from main l10n to _always_ be used in Pocket
mode, regardless of locale.
  • Loading branch information
stevejalim committed Apr 27, 2022
1 parent d2b428e commit 33dd465
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
6 changes: 5 additions & 1 deletion bedrock/pocket/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
from bedrock.mozorg.util import page

urlpatterns = (
page("about/", "pocket/about.html"),
page(
"about/",
"pocket/about.html",
ftl_files=["pocket/about"],
),
page("add/", "pocket/add.html"),
page("android/", "pocket/android.html"),
page("ios/", "pocket/ios.html"),
Expand Down
15 changes: 11 additions & 4 deletions bedrock/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@

site_mode = config("SITE_MODE", default=MOZORG_SITE_MODE)

if site_mode == POCKET_SITE_MODE:
IS_POCKET_MODE = site_mode == POCKET_SITE_MODE
IS_MOZORG_MODE = not IS_POCKET_MODE

if IS_POCKET_MODE:
ROOT_URLCONF = "bedrock.urls.pocket_mode"

# DROP the redirects app and middleware, because it's contains Mozorg-specific rules that
Expand All @@ -106,11 +109,15 @@
# TODO: define in Pocket-appropriate versions of
# DEV_LANGUAGES, PROD_LANGUAGES, CANONICAL_LOCALES,
# FLUENT_* overrides for Pocket L10N, etc
FLUENT_DEFAULT_FILES = [
"nav",
"footer",
]
FLUENT_POCKET_LOCAL_PATH = ROOT_PATH / "l10n-pocket"
FLUENT_PATHS.insert(0, FLUENT_POCKET_LOCAL_PATH)

else:
ROOT_URLCONF = "bedrock.urls.mozorg_mode"
# TODO: move Mozorg-appropriate versions of
# DEV_LANGUAGES, PROD_LANGUAGES, CANONICAL_LOCALES,
# FLUENT_* overrides for Pocket L10N into this file

# TEST-SPECIFIC SETTINGS
# TODO: make this selectable by an env var, like the other modes
Expand Down
5 changes: 3 additions & 2 deletions bedrock/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ def data_path(*args):

GITHUB_REPO = "https://github.com/mozilla/bedrock"

# Default l10n config is for mozorg. See settings/__init__.py for where we [will] plug in
# an alternative Pocket-appropriate l10n setup.
# IMPORTANT: The default l10n config here is for Mozorg. See settings/__init__.py
# for where we plug in an alternative Pocket-appropriate l10n setup.

# Global L10n files.
FLUENT_DEFAULT_FILES = [
"banners/firefox-app-store",
Expand Down
3 changes: 1 addition & 2 deletions lib/l10n_utils/fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ def load_fluent_resources(root, locale, resource_ids):

resources.append(load_fluent_file(path))
if resources:
if locale != "en":
if locale != "en" or settings.IS_POCKET_MODE:
path = settings.FLUENT_LOCAL_PATH.joinpath("en", "brands.ftl")
resources.append(load_fluent_file(path))

return resources


Expand Down

0 comments on commit 33dd465

Please sign in to comment.