File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ client.previousPage();
162162
163163#### Define language filter
164164``` 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" )
166166client .setLanguage (' en' );
167167```
168168
Original file line number Diff line number Diff line change @@ -58,10 +58,20 @@ var settings = function() {
5858 }
5959
6060 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\")" ;
6373 }
64- this . settings . lang = language ;
74+ this . settings . lang = languageIntlLocale ;
6575 }
6676
6777 this . setFuzzyMatch = function ( fuzzy ) {
You can’t perform that action at this time.
0 commit comments