Hello Everyone,
I have a use case to implement same components but with different styles(UI) for 21 different locales. What should be the best approach for this. I don't want to extend components or add conditions for locale in the generic components.
@arunpatidar @VeenaVikraman @Theo_Pendle @ArpitVarshney
Solved! Go to Solution.
Views
Replies
Total Likes
There are few different ways. In general, below approaches are popular.
1. Use Style System: Use this approach, If you want to provide a authoring capability for authors to select the style system: https://docs.adobe.com/content/help/en/experience-manager-65/developing/components/style-system.html
2. Use HTML Attributes/CSS Selectors: Sometimes, we want to roll some styles globally on specific languages. This is most common use can you can use HTML attributes to define the styles specific to a language/locale.
Ex:
html:lang(ja) {
font-family: "Arial",Helvetica;
}
@Veenu Use the Style System , where you can create your custom policies and apply it to a component.
It's pretty cool!!
Thanks,
Nikhil
There are few different ways. In general, below approaches are popular.
1. Use Style System: Use this approach, If you want to provide a authoring capability for authors to select the style system: https://docs.adobe.com/content/help/en/experience-manager-65/developing/components/style-system.html
2. Use HTML Attributes/CSS Selectors: Sometimes, we want to roll some styles globally on specific languages. This is most common use can you can use HTML attributes to define the styles specific to a language/locale.
Ex:
html:lang(ja) {
font-family: "Arial",Helvetica;
}
My 2 cents is that the style system can be used, but it may negatively impact authors the need to be very accurate with content configuration. Instead, I would change colors or icons in the code, and use the CSS selector: :lang() to tackle this situation (supported on most browsers); https://caniuse.com/#search=%3Alang
HTML:
<html lang="en">
...
</html>
<html lang="fr">
...
</html>
CSS / SCSS:
// CSS
.button:lang(en) {
background: yellow;
}
.button:lang(fr) {
background: red;
}
// SCSS
.button {
&:lang(en) {
background: yellow;
}
&:lang(fr) {
background: red;
}
}
Hi,
What can you use is locale-dependent clientlibs for components/templates. For example - you have a text component and locales en-us and en-ca. Create a clientlib with name project.text.en-us and project.text.ca-us (PROJECT.COMPONENT_NAME.LOCALE) and fetch the component name and locale in HTL and create this clientlib name and call the clientlib in this way you don't have to add any manual efforts for the author and this will be generic for multiple locales and u can add more in future.
you can inject a locale class in your component's wrapper div and write style for that
e.g. Model
Resource resource = resourceResolver.getResource(path); if (resource != null) { Page targetPage = resource.adaptTo(Page.class); if (targetPage != null) { Locale pageLocale = targetPage.getLanguage(true); String countryLocale = "cmp_mycmp__local_"+pageLocale.getCountry(); } }
HTL
<div data-sly-use.obj="com.proj.core.models.CompModel" class="Some_class more_classes ${obj.countryLocaleClass ? obj.countryLocaleClass : ''}">
Views
Likes
Replies
Views
Likes
Replies