Feature: add metadata to translations
See original GitHub issueI want to add some metadata to translations, which would also be extracted during lingui extract
process.
Use case: I want to specify the type of the translation, and later, in the CMS, present the user with a different editor based on the translation type.
<h1 className="title">
<Trans id="home.title" type="text">Page title</Trans>
</h1>
<p className="lead">
<Trans id="home.lead"" type="textarea">Some long text, bla bla. Users will expect textarea or maybe even rich text editor</Trans>
</p>
I can write a custom extractor to do this, but I was thinking that maybe we can add support for this directly to the Lingui library. What do you think? Does it make sense to put metadata on translations?
To be honest, I haven’t really thought things through 😃 I mean, I could easily write my message ids like ${ns}.${key}.${type}
😃
<Trans id="home.title.text" />
or
<Trans id="home.lead.textarea" />
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Translating Metadata to a Different Language
You can translate your metadata by modifying the default values using a JavaScript add-on. Through the add-on, you define the new values to...
Read more >Metadata Translation
In situations where Salesforce doesn't provide default translations, metadata translation allows you to localize apps and custom functionality that you build in ...
Read more >Provide metadata translations in bulk
Import translated metadata · Open the Items page icon · Click the arrow next to the Add new items button · Choose Advanced...
Read more >Automating Translations of Asset Metadata
Translate Metadata Fields · Loop over each of the metadata fields that require translation and call the custom block with sourceText , ...
Read more >Import metadata translation - Power Apps
To import metadata translation · Open Power Apps portals admin center. · Go to Portal Actions > Get latest metadata translations. A confirmation ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, it should be possible to add metadata when using
lingui
format.One metadata I have thought about was help text for translators:
This would be extracted as:
We might use similar syntax to add other
meta tags
depending on usecase.I’m not 100% convinced about
type
as it could be guessed from content (e.g: type = text, markdown, icu).RFC - support metadata in js.macro
t
macro is the same asi18n.t
what we have now. If we want to add support for metadata, we need to figure out all possible variation, how the macro is used.Description is
type Description = string | Object
, where object might contain arbitrary data. Using string is a shortcut for{ description: string }
object.The problem is, that using Description as a string clashes with message ID, which is also a string. In simple usecase
t("hello")'Message'
it’s impossible to determine whetherhello
is ID or description.Please vote with reaction or suggest different API.
Variation 👍
t
template tag is used for all messages. Description must be always second argument.Variation ❤️
t
template tag is used only for messages used as IDs,t.id
template tag is used for messages with custom IDs