DEV Community

Vishang
Vishang

Posted on

How to add lang option in custom components.

How to add language option with custom component using CRXDE

Scenario Adding three language option with your custome component. English, Spanish and French.

Create i18n folder in your component.
Create Subfolders for each languages within i18n
en
es
fr
Component structure will look like this 👇

i18n base folder structure

Add Mixins.. to these folders with type mix:language
add mixins to lang folder

After adding mixins. Add a property called jcr:language with language iso code i.e french it will be fr

Within those folder create node with exect same name as an item in your component with primaryType: sling:MessageEntry
Now add two properties

  1. sling:key
  2. sling:message Sling:key is same for all language and change the sling:message properties with your desire custom value in each language. key and message property

Test
Change the prefered language from profile->prefrences and check in the component weather the lang is chages to your custom meesage attached to the lanaguage.

Hope this is helpful.

Thank you!

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay