[MAGNOLIA-6470] Offer possibility to override template translations Created: 23/Dec/15  Updated: 11/Mar/21  Resolved: 11/Mar/21

Status: Closed
Project: Magnolia
Component/s: freemarker
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Roman Kovařík Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
dependency
depends upon MAGNOLIA-6472 Support injection into i18n key gener... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Epic Link: Enhancement of i18n

 Description   

It's possible to override a messages in a FTL template by specifying a custom i18nbase.
We could provide a different solution since the base name is deprecated.
It could be a key generator in the MessageWrapper which would generated the keys:
FTL: i18n[my.key]

public String get(String key) {
        return translationService.translate(localeProvider, base name,  
                               Components.getComponent(TemplateKeyGenerator.class).generate(key)});
}

class TemplateKeyGenerator {
     String[] generate(){
         return new String{key, site name + key};
     }
}

It would be possible to define a custom TemplateKeyGenerator via module descriptor. E.g. Site module would bring a SiteAwareTemplateKeyGenerator.
Be aware that this is different than other info.magnolia.i18nsystem.I18nKeyGenerator s since those generates keys from nothing. Here we need to generated additional keys to the provided one.


Generated at Mon Feb 12 04:14:50 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.