react-localization 1.0.14 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -13,7 +13,7 @@ The library uses the current interface language, then it loads and displays the
13
13
 
14
14
  It's possible to force a language different from the interface one.
15
15
 
16
- ##Installation
16
+ ## Installation
17
17
 
18
18
  `npm install --save react-localization`
19
19
 
@@ -73,7 +73,7 @@ strings.setContent({
73
73
  * setLanguage(languageCode) - to force manually a particular language
74
74
  * getLanguage() - to get the current displayed language
75
75
  * getInterfaceLanguage() - to get the current device interface language
76
- * formatString() - to format the passed string replacing its placeholders with the other arguments strings
76
+ * formatString() - formats the input string and returns a new string, replacing its placeholders with the other arguments strings
77
77
  ```js
78
78
  en:{
79
79
  bread:"bread",
@@ -103,6 +103,17 @@ strings.setContent({
103
103
  year: 2018
104
104
  })
105
105
  ```
106
+
107
+ Typical usage is to render it in a JSX with `formatString` calls inlined:
108
+
109
+ ```jsx
110
+ <div>
111
+ <SomeComponent food={strings.formatString(strings.question, strings.bread, "jam")} />
112
+ <p>Usage with an object parameter: {
113
+ strings.formatString(strings.currentDate, { month: "February", day: 13, year: 2050 })
114
+ }></p>
115
+ </div>
116
+ ```
106
117
  **Beware: do not define a string key as formatString!**
107
118
 
108
119
  * setContent(props) - to dynamically load another set of strings
@@ -9,7 +9,7 @@ declare module 'react-localization' {
9
9
  export interface LocalizedStringsMethods {
10
10
  /**
11
11
  * Can be used from ouside the class to force a particular language
12
- * indipendently from the interface one
12
+ * independently from the interface one
13
13
  * @param language
14
14
  */
15
15
  setLanguage(language: string): void;
@@ -43,7 +43,7 @@ declare module 'react-localization' {
43
43
  * @param key
44
44
  * @param language
45
45
  */
46
- getString(key: string, language: string): string;
46
+ getString(key: string, language?: string, omitWarning?: boolean): string;
47
47
 
48
48
  /**
49
49
  * Replace the NamedLocalization object without reinstantiating the object
@@ -54,8 +54,17 @@ declare module 'react-localization' {
54
54
 
55
55
  export type LocalizedStrings<T> = LocalizedStringsMethods & T;
56
56
 
57
+ type GetInterfaceLanguageCallback = () => string;
58
+
59
+ interface Options {
60
+ customLanguageInterface?: GetInterfaceLanguageCallback;
61
+ logsEnabled?: boolean;
62
+ pseudo?: boolean;
63
+ pseudoMultipleLanguages?: boolean;
64
+ }
65
+
57
66
  interface LocalizedStringsFactory {
58
- new <T>(props: GlobalStrings<T>): LocalizedStrings<T>;
67
+ new <T>(props: GlobalStrings<T>, options?: Options): LocalizedStrings<T>;
59
68
  }
60
69
 
61
70
  var LocalizedStrings: LocalizedStringsFactory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-localization",
3
- "version": "1.0.14",
3
+ "version": "1.0.18",
4
4
  "description": "Simple module to localize the React interface using the same syntax used in the ReactNativeLocalization module, use 'npm run build' before publishing",
5
5
  "scripts": {
6
6
  "babel-version": "babel --version",
@@ -35,12 +35,12 @@
35
35
  "babel-preset-react": "^6.24.1",
36
36
  "babel-preset-stage-2": "^6.24.1",
37
37
  "jasmine": "^2.7.0",
38
- "react": "^16.0.0"
38
+ "react": "^15.6.0"
39
39
  },
40
40
  "dependencies": {
41
41
  "localized-strings": "^0.2.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "react": "^16.0.0 || ^15.6.0"
44
+ "react": "^17.0.0 || ^16.0.0 || ^15.6.0"
45
45
  }
46
46
  }
package/.DS_Store DELETED
Binary file