Security News
pnpm 9.5 Introduces Catalogs: Shareable Dependency Version Specifiers
pnpm 9.5 introduces a Catalogs feature, enabling shareable dependency version specifiers, reducing merge conflicts and improving support for monorepos.
@brandingbrand/fsi18n
Advanced tools
Readme
Internationalization helper for Flagship. Automatically reads the user's current locale and uses it to format numbers, dates, and strings.
Uses react-native-i18n/i18n-js for strings, Number.prototype.toLocaleString for numbers, and Date.prototype.toLocaleString under the hood.
yarn add @brandingbrand/fsi18n
yarn add react-native-i18n
The react-native-i18n
package must be added to your project as a dependency so the native modules
will link correctly.
Assume the user's language preference is set to French (fr-FR).
import FSI18n from '@brandingbrand/fsi18n';
const translations = {
en: {
greeting: 'Hello',
},
fr: {
greeting: 'Bonjour',
},
es: {
greeting: 'Hola',
},
};
FSI18n.addTranslations(translations);
FSI18n.string('greeting'); // Bonjour
import FSI18n from '@brandingbrand/fsi18n';
FSI18n.number(1234.56); // 1 234,56
import FSI18n from '@brandingbrand/fsi18n';
FSI18n.currency(1234.56, 'EUR'); // 1 234,56 €
FSI18n.currency(1234.56, undefined, {
currency: 'USD',
currencyDisplay: 'code',
}); // 1 234,56 USD
import FSI18n from '@brandingbrand/fsi18n';
FSI18n.percent(0.123456); // 12 %
import FSI18n from '@brandingbrand/fsi18n';
const importantDate = new Date('Nov 1, 2018');
FSI18n.date(importantDate); // 01/11/2018
Some clients might want Australian dollars to display as "A$ 19.99" instead of the default "AUD 19.99"
To get this to work you need represent each currency you want to override as a key value pair with the key being a three character ISO-4217 currency code and the value being the desired symbol.
IOS-4217 standard: https://www.iso.org/iso-4217-currency-codes.html
Here is an example of using the addCurrencyOverrides()
import FSI18n, { MappedCurrencySymbols } from '@brandingbrand/fsi18n';
const currencyOverrides: MappedCurrencySymbols = {
AUD: 'A$',
USD: 'US$',
};
FSI18n.addCurrencyOverrides(currencyOverrides);
FAQs
Unknown package
We found that @brandingbrand/fsi18n demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 92 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
pnpm 9.5 introduces a Catalogs feature, enabling shareable dependency version specifiers, reducing merge conflicts and improving support for monorepos.
Security News
A threat actor on BreachForums is selling an unverified npm vulnerability for account takeover, but npm has not officially confirmed the existence of this security concern.
Security News
Cyber insurance rates are dropping as the market matures, according to a new report projecting global premiums to reach $43 billion by 2030, driven by international market uptake and growth in the SME sector.