File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-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,16 @@ 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+ try {
63+ languageIntlLocale = new Intl . Locale ( language ) . language ;
64+ } catch ( e ) {
65+ throw "use accepted language code provided by ECMAScript Internationalization API (e.g. \"en\", \"en-GB\")" ;
6366 }
64- this . settings . lang = language ;
67+ if ( languageIntlLocale && languageIntlLocale . length !== 2 ) {
68+ throw "use 2-char/4-char language code (e.g. \"en\", \"en-GB\")" ;
69+ }
70+ this . settings . lang = languageIntlLocale ;
6571 }
6672
6773 this . setFuzzyMatch = function ( fuzzy ) {
You can’t perform that action at this time.
0 commit comments