2018-11-30 14:35:04 +00:00
|
|
|
// @flow
|
2017-03-01 02:55:12 +00:00
|
|
|
|
2018-11-30 14:35:04 +00:00
|
|
|
import { NativeModules } from 'react-native';
|
2017-03-01 02:55:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The singleton language detector for React Native which uses the system-wide
|
|
|
|
* locale.
|
|
|
|
*/
|
|
|
|
export default {
|
|
|
|
/**
|
|
|
|
* Does not support caching.
|
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
cacheUserLanguage: Function.prototype,
|
|
|
|
|
|
|
|
detect() {
|
2018-11-30 14:35:04 +00:00
|
|
|
const { LocaleDetector } = NativeModules;
|
|
|
|
|
|
|
|
return LocaleDetector.locale.replace(/_/, '-');
|
2017-03-01 02:55:12 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
init: Function.prototype,
|
|
|
|
|
|
|
|
type: 'languageDetector'
|
|
|
|
};
|