File tree 2 files changed +14
-4
lines changed
2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ client.previousPage();
162
162
163
163
#### Define language filter
164
164
``` js
165
- // Fetch documents in specific language (e.g. "en" or "de")
165
+ // Fetch documents in specific language (e.g. "en" or "de" or "en-GB" )
166
166
client .setLanguage (' en' );
167
167
```
168
168
Original file line number Diff line number Diff line change @@ -58,10 +58,20 @@ var settings = function() {
58
58
}
59
59
60
60
this . setLanguage = function ( language ) {
61
- if ( language && language . length !== 2 ) {
62
- throw "use 2-char language code (e.g. \"en\")" ;
61
+ var languageIntlLocale ;
62
+ if ( Intl && Intl . Locale ) {
63
+ try {
64
+ languageIntlLocale = new Intl . Locale ( language ) . language ;
65
+ } catch ( e ) {
66
+ throw "use accepted language code provided by ECMAScript Internationalization API (e.g. \"en\", \"en-GB\")" ;
67
+ }
68
+ } else {
69
+ languageIntlLocale = language ;
70
+ }
71
+ if ( languageIntlLocale && languageIntlLocale . length !== 2 ) {
72
+ throw "use 2-char/4-char language code (e.g. \"en\", \"en-GB\")" ;
63
73
}
64
- this . settings . lang = language ;
74
+ this . settings . lang = languageIntlLocale ;
65
75
}
66
76
67
77
this . setFuzzyMatch = function ( fuzzy ) {
You can’t perform that action at this time.
0 commit comments