Find a better way to manage home page promos across multiple locales

VERIFIED FIXED

Status

VERIFIED FIXED
5 years ago
5 years ago

People

(Reporter: craigcook, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [kb=1194646] , URL)

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
Every time we add/change one of the four promos on the home page, there's a period of time when some locales have to fall back to the previously translated promo for that slot until they can translate the new strings. So far we've been handling this with an array of locales for each new promo and some simple boolean rules in the template. That clearly doesn't scale well. It means a new array for every new promo, and requires a code change and production push every time we activate more locales. 

We need a better method of specifying which promos are visible for a given locale, or rather which locales have translated a given promo. Now that we have a database, I'm thinking it could be something we manage through the django admin.
(Reporter)

Updated

5 years ago
Whiteboard: [kb=1194646]
It would be nice if this could be handled like activation flags in the lang files as they're fully reliant on the translation and nothing else. So I have an idea:

We could use a lang file "tag" per promo. So we'd have 4 at a time and could retire them as they rotate out. This would basically work like this:

1. Add a new promo to the home page, but wrap it in code similar to the following:

{% if lang_file_has_tag('promo_surfing') %} Surfin' USA! {% else %} Old & Busted {% endif %}

2. Once a locale is ready for the new promo, the following would be added to the top
   of the lang file:

## promo_surfing ##

3. When that lang file change is pushed to prod the new promo would show on the home page
   for that locale.

The lang_file_has_tag() function would always return true for en-US. I like this better than
the DB because it keeps the information about what is translated where it's been, and means
that our l10n managers can control the enablement of the promos completely autonomously. It
would also only take a small code change to make this happen. We already have the generic tag
checking ability, we just need the template function.
What do you think of my suggestion from comment #1 :pascalc?
Flags: needinfo?(pascalc)
I like the idea of using tags, if I undestand well, home.lang top of the file woul look like that right?:
## active ##
## promo_surfing ##
## promo_webmaker ##

;some string in English
Une chaine en français
Flags: needinfo?(pascalc)

Comment 4

5 years ago
(In reply to Pascal Chevrel:pascalc from comment #3)
> I like the idea of using tags, if I undestand well, home.lang top of the
> file woul look like that right?:
> ## active ##
> ## promo_surfing ##
> ## promo_webmaker ##
> 
> ;some string in English
> Une chaine en français

Do we have to prefix the tags with something like tag:promo_surfing and split on the ":"? I was just thinking the tag would make it more explicit to people looking at the file to know the purpose of those strings. This may be helpful with contributors who may not know the nomenclature of the metadata in the file.
(In reply to Pascal Chevrel:pascalc from comment #3)
> I like the idea of using tags, if I undestand well, home.lang top of the
> file woul look like that right?:
> ## active ##
> ## promo_surfing ##
> ## promo_webmaker ##
> 
> ;some string in English
> Une chaine en français

Exactly right.

(In reply to Chris More [:cmore] from comment #4) 
> Do we have to prefix the tags with something like tag:promo_surfing and
> split on the ":"? I was just thinking the tag would make it more explicit to
> people looking at the file to know the purpose of those strings. This may be
> helpful with contributors who may not know the nomenclature of the metadata
> in the file.

We can call them anything we want. Adding the "promo_" prefix was my attempt at doing this kind of thing. We don't currently support splitting on anything, we can just check for a tag with "active" being one of those tags:

lang_file_has_tag('mozorg/home', 'surfing', 'de')

That'll be True if de/mozorg/home.lang has the ## surfing ## tag. I don't really see a need to call them out with the word "tag" since as far as I know we've had no issues using these tags so far. We do have at least one tag in use other than "active". Pascal is in a better spot to say whether we need any extra info in the file though.
Created attachment 8344751 [details] [review]
pull request

Adds the ability to easily check for a langfile tag from a template.

Comment 7

5 years ago
Commits pushed to master at https://github.com/mozilla/bedrock

https://github.com/mozilla/bedrock/commit/afa188a424b3cab1f8daff29eeb24373740aa4c8
Bug 942273: Add template helper for langfile tags.

https://github.com/mozilla/bedrock/commit/87207a6f79e2d2a1bae9a5edf004f0ad6918fc64
Merge pull request #1488 from pmclanahan/add-lang-file-tag-helper-942273

Bug 942273: Add template helper for langfile tags.
fixed on stage https://www.allizom.org/en-US/
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.