![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@appnest/lit-translate
Advanced tools
A lightweight internationalization (i18n) library for your lit-html based projects
This is a lightweight internationalization (i18n) library for your lit-html based project (or any other project for that matter).
Overview
lit-html
directive that automatically updates when the language updates.get("home.header.title")
)npm i @appnest/lit-translate
// en.json
{
"lang": "en",
"header": {
"title": "Hello",
"subtitle": "World"
},
"cta": {
"awesome": "{{ things }} are awesome!",
"cats": "Cats"
}
}
Use the function getStrings
to load the strings at a given path. If you want to cache the strings for next time you are using the getStrings
function, you might want to cache the result using the function addStringsToCache
using the path as key.
const path = `/assets/i18n/en.json`;
const strings = await getStrings(path);
addStringsToCache(path, strings);
Use the function setStrings
to set the current strings of the language. When this function is invoked, the event stringsChanged
will be dispatched on the window object.
await setStrings(strings);
To get a translated string use the function get
. Give this function a string with the chain of keys that points to the desired string in the JSON structure. The below example is based on the strings defined in step 1
.
get("lang"); // "en"
get("header.title"); // "Hello"
get("header.subtitle"); // "World"
Using the get
function it is possible to interpolate values. Simply use the {{ key }}
syntax in your strings and provide an object with values replacing those defined in the string when using the get
function. The below example is based on the strings defined in step 1
.
get("cta.awesome", { thing: get("cta.cats") )); // Cats are awesome!
translate
directiveIf you are using lit-html
you might want to use the translate
directive. This directive makes sure to automatically update all of the translated parts when the method setStrings
is called and the stringsChanged
event is dispatched on the window object.
class MyComponent extends LitElement {
render () {
html`
<h1>${translate("header.title")}</h1>
<p>${translate("header.subtitle")}</p>
<span>${translate("cta.awesome", {things: get("cta.cats") })}</span>
`;
}
}
Licensed under MIT.
FAQs
A lightweight blazing-fast internationalization (i18n) library for your next web-based project
The npm package @appnest/lit-translate receives a total of 0 weekly downloads. As such, @appnest/lit-translate popularity was classified as not popular.
We found that @appnest/lit-translate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.