Skip to content

Commit 45cebfa

Browse files
committed
Fixes compatibilty with latest version of localized-strings
1 parent fb1c7c2 commit 45cebfa

File tree

2 files changed

+34
-33
lines changed

2 files changed

+34
-33
lines changed

lib/LocalizedStrings.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
* Check the instructions at:
1212
* https://github.com/stefalda/ReactNativeLocalization
1313
*/
14-
'use strict';
14+
"use strict";
1515

1616
Object.defineProperty(exports, "__esModule", {
1717
value: true
1818
});
1919

20-
var _reactNative = require('react-native');
20+
var _reactNative = require("react-native");
2121

22-
var _reactLocalization = require('react-localization');
22+
var _reactLocalization = require("react-localization");
2323

2424
var _reactLocalization2 = _interopRequireDefault(_reactLocalization);
2525

@@ -31,9 +31,9 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
3131

3232
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
3333

34-
/**
34+
/**
3535
* Import the native module
36-
*/
36+
*/
3737
var localization = _reactNative.NativeModules.ReactLocalization;
3838
/**
3939
* Check if the native module has been correctly initialized
@@ -42,25 +42,25 @@ if (!localization) {
4242
console.error("Something went wrong initializing the native ReactNativeLocalization module.\nPlease check your configuration.\nDid you run 'react-native link'?");
4343
}
4444

45-
/**
45+
/**
4646
* Custom Interface Language method returned by native code
47-
*/
47+
*/
4848
function getInterfaceLanguage() {
49-
return localization.language.replace(/_/g, '-');
49+
return localization.language.replace(/_/g, "-");
5050
}
5151

52-
/**
53-
* Extend the react-localization class overriding the getInterfaceLanguage method
54-
* to use the native module
55-
*/
52+
/**
53+
* Extend the react-localization class overriding the getInterfaceLanguage method
54+
* to use the native module
55+
*/
5656

5757
var LocalizedStrings = function (_LocalizedStringsCore) {
5858
_inherits(LocalizedStrings, _LocalizedStringsCore);
5959

6060
function LocalizedStrings(props) {
6161
_classCallCheck(this, LocalizedStrings);
6262

63-
return _possibleConstructorReturn(this, (LocalizedStrings.__proto__ || Object.getPrototypeOf(LocalizedStrings)).call(this, props, getInterfaceLanguage));
63+
return _possibleConstructorReturn(this, (LocalizedStrings.__proto__ || Object.getPrototypeOf(LocalizedStrings)).call(this, props, { customLanguageInterface: getInterfaceLanguage }));
6464
}
6565

6666
return LocalizedStrings;

src/LocalizedStrings.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,35 @@
1111
* Check the instructions at:
1212
* https://github.com/stefalda/ReactNativeLocalization
1313
*/
14-
'use strict';
15-
import { NativeModules } from 'react-native';
16-
import LocalizedStringsCore from 'react-localization';
17-
/**
14+
"use strict";
15+
import { NativeModules } from "react-native";
16+
import LocalizedStringsCore from "react-localization";
17+
/**
1818
* Import the native module
19-
*/
19+
*/
2020
const localization = NativeModules.ReactLocalization;
2121
/**
2222
* Check if the native module has been correctly initialized
2323
*/
2424
if (!localization) {
25-
console.error("Something went wrong initializing the native ReactNativeLocalization module.\nPlease check your configuration.\nDid you run 'react-native link'?");
25+
console.error(
26+
"Something went wrong initializing the native ReactNativeLocalization module.\nPlease check your configuration.\nDid you run 'react-native link'?"
27+
);
2628
}
2729

28-
29-
/**
30+
/**
3031
* Custom Interface Language method returned by native code
31-
*/
32-
function getInterfaceLanguage(){
33-
return localization.language.replace(/_/g, '-');
34-
}
32+
*/
33+
function getInterfaceLanguage() {
34+
return localization.language.replace(/_/g, "-");
35+
}
3536

36-
/**
37-
* Extend the react-localization class overriding the getInterfaceLanguage method
38-
* to use the native module
39-
*/
40-
export default class LocalizedStrings extends LocalizedStringsCore{
41-
constructor(props){
42-
super(props, getInterfaceLanguage);
37+
/**
38+
* Extend the react-localization class overriding the getInterfaceLanguage method
39+
* to use the native module
40+
*/
41+
export default class LocalizedStrings extends LocalizedStringsCore {
42+
constructor(props) {
43+
super(props, { customLanguageInterface: getInterfaceLanguage });
4344
}
44-
}
45+
}

0 commit comments

Comments
 (0)