![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
mobx-translate
Advanced tools
npm install mobx-translate --save
First, create interface for your translations:
export interface TranslationKeys {
list: {
HEADING
MORE
},
widget: {
HELLO
BYE
}
}
Then, define your strings. With code completion for keys, and full Mustache template support in values:
import {TranslationKeys} from './translation-keys';
export const EN:TranslationKeys = {
list: {
HEADING: 'Available jobs',
MORE: 'More'
},
widget: {
HELLO: 'Hello {{name}}',
BYE: 'Bye {{name}}'
}
}
export const DE:TranslationKeys = {
list: {
HEADING: "Verfügbare Berufe",
MORE: "Mehr"
},
widget: {
HELLO: "Gutten tag {{name}}",
BYE: "Auf wiedersehn {{name}}"
}
}
Initialize MobxTranslate, pass your translations interface as a generic:
import {TranslationKeys} from './strings/translation-keys';
import {MobxTranslate} from './mobx-translate';
import {EN} from './strings/en';
import {DE} from './strings/de';
const translateInstance = new MobxTranslate<TranslationKeys>();
translateInstance.loadStrings('EN', EN);
translateInstance.loadStrings('DE', DE);
translateInstance.setLanguage('EN');
export const trans = translateInstance;
And then easily switch languages and translate strings in React components. Again, with code completion for translation keys!:
import * as React from 'react';
import {observer} from 'mobx-react';
import {trans} from '../stores/translate';
@observer
export class Foo extends React.Component<{}, {}> {
render() {
return (
<div className="container">
<h1>{trans.key.widget.HELLO({name: 'Joe'})}</h1>
<button onClick={trans.setLanguage.bind(trans,'EN')}>EN</button>
<button onClick={trans.setLanguage.bind(trans,'DE')}>DE</button>
<h1>{trans.key.list.HEADING()}</h1>
</div>)
}
}
FAQs
Simple translations library for mobx
The npm package mobx-translate receives a total of 10 weekly downloads. As such, mobx-translate popularity was classified as not popular.
We found that mobx-translate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
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.