All Projects β†’ galkinrost β†’ react-intlable

galkinrost / react-intlable

Licence: MIT license
High order component for declarative Internationalization

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to react-intlable

Globalize
A JavaScript library for internationalization and localization that leverages the official Unicode CLDR JSON data
Stars: ✭ 4,612 (+19952.17%)
Mutual labels:  intl
Kiwi
🐀 Kiwi-ε›½ι™…εŒ–ε…¨ζ΅η¨‹θ§£ε†³ζ–Ήζ‘ˆ
Stars: ✭ 1,872 (+8039.13%)
Mutual labels:  intl
Laravel Intl
🚫 [ABANDONED] Easy to use internationalization/localization functions for Laravel 5
Stars: ✭ 185 (+704.35%)
Mutual labels:  intl
Translation
The Translation component provides tools to internationalize your application.
Stars: ✭ 6,196 (+26839.13%)
Mutual labels:  intl
Date Time Format Timezone
Surgically polyfills timezone support in Intl.DateTimeFormat API
Stars: ✭ 94 (+308.7%)
Mutual labels:  intl
App Datepicker
Datepicker element built with Google's lit-element and Material Design 2
Stars: ✭ 142 (+517.39%)
Mutual labels:  intl
Psl
PHP Standard Library - a modern, consistent, centralized, well-typed set of APIs for PHP programmers.
Stars: ✭ 329 (+1330.43%)
Mutual labels:  intl
arbify flutter
Flutter package providing Arbify support.
Stars: ✭ 18 (-21.74%)
Mutual labels:  intl
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (+339.13%)
Mutual labels:  intl
Formatjs
The monorepo home to all of the FormatJS related libraries, most notably react-intl.
Stars: ✭ 12,869 (+55852.17%)
Mutual labels:  intl
Fluent
Fluent β€” planning, spec and documentation
Stars: ✭ 818 (+3456.52%)
Mutual labels:  intl
Aura.intl
Internationalization tools, particularly message translation.
Stars: ✭ 82 (+256.52%)
Mutual labels:  intl
Jquery.ime
jQuery based input methods library
Stars: ✭ 145 (+530.43%)
Mutual labels:  intl
Jquery.i18n
🌐jQuery based internationalization library
Stars: ✭ 577 (+2408.7%)
Mutual labels:  intl
Intl
A PHP replacement layer for the C intl extension that also provides access to the localization data of the ICU library.
Stars: ✭ 2,323 (+10000%)
Mutual labels:  intl
Ember Intl
Localization library for any Ember Application or Addon
Stars: ✭ 412 (+1691.3%)
Mutual labels:  intl
Luxon
⏱ A library for working with dates and times in JS
Stars: ✭ 11,926 (+51752.17%)
Mutual labels:  intl
next-intl
Library to integrate react-intl with Next.js.
Stars: ✭ 41 (+78.26%)
Mutual labels:  intl
Sonataintlbundle
Symfony SonataIntlBundle
Stars: ✭ 212 (+821.74%)
Mutual labels:  intl
Arbify
ARB files localization tool. Dedicated to Flutter and its intl package.
Stars: ✭ 168 (+630.43%)
Mutual labels:  intl

React intlable Build Status

intl-messageformat bindings for React

Installation

npm install --save intl-messageformat react-intlable

Implementation

import React from 'react'
import { IntlableProvider } from 'react-intlable'

import Application from './Application'

const { messages, locale } = window.__LOCALE_DATA__

const ApplicationContainer = () => (
  <IntlableProvider messages={messages} locale={locale}>
    <Application />
  </IntlableProvider>
)

Decorator

import React from 'react'
import { intlable } from 'react-intlable'

const Application = ({formatMessage, formatDate, formatNumber}) => (
  <div>
    <h1>{formatMessage(`application.greeting`, { name: `World`})}</h1>
    <p>{formatDate(new Date())}</p>
    <p>{formatNumber(100, { style: `currency`, currency: `USD`, currencyDisplay: `symbol` })</p>
  </div>
)

export default intlable(Application)

Messages

Simple object

{
  application: {
    greeting: `Hello {name}!`
  }
}

Browser support

Can i use

If you want fully cross browser support, these steps for you:

Install inlt polyfill

npm install --save intl

Use ready loader

import AppContainer from './AppContainer'
import React from 'react'
import ReactDOM from 'react-dom'
import {ready} from 'react-intlable'

import pathToLocale from 'intl/locale-data/json/en.json'

ready(pathToLocale, () => {
    ReactDOM.render(<AppContainer />, document.getElementById(`app`))
})

pathToLocale is a public url for localization data required by intl polyfill

If you use webpack, you can use file-loader to get this url

{
    test: /\.json$/,
    loader: `file?name=[hash].[ext]`
}

Universal rendering

Example

For consistent results of internationalization you should use polyfill both on server and client

On server

global.Intl = require(`intl`)
require(`intl/locale-data/jsonp/en.js`)
require(`intl/locale-data/jsonp/eu.js`)
...

And force loading required data on client

ready(pathToLocale, () => {
    ReactDOM.render(<AppContainer />, document.getElementById(`app`))
}, true)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].