Skip to content

Commit

Permalink
Change name to path
Browse files Browse the repository at this point in the history
  • Loading branch information
terhuerne committed Apr 5, 2018
1 parent 2b669f6 commit 04c2c37
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is a i18next language detection plugin use to detect user language in the b
- navigator
- querystring (append `?lng=LANGUAGE` to URL)
- htmlTag
- url
- path

# Getting started

Expand Down Expand Up @@ -45,13 +45,13 @@ As with all modules you can either pass the constructor function (class) to the
```js
{
// order and from where user language should be detected
order: ['querystring', 'cookie', 'localStorage', 'navigator', 'htmlTag'],
order: ['querystring', 'cookie', 'localStorage', 'navigator', 'htmlTag', 'path'],

// keys or params to lookup language from
lookupQuerystring: 'lng',
lookupCookie: 'i18next',
lookupLocalStorage: 'i18nextLng',
lookupFromUrlIndex: 0,
lookupFromPathIndex: 0,

// cache user language on
caches: ['localStorage', 'cookie'],
Expand Down
8 changes: 4 additions & 4 deletions i18nextBrowserLanguageDetector.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@
}
};

var folder = {
name: 'folder',
var path = {
name: 'path',

lookup: function lookup(options) {
var found = void 0;
if (typeof window !== 'undefined') {
var language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
if (language instanceof Array) {
if (typeof options.lookupFromUrlIndex === 'number') {
found = language[options.lookupFromFolderIndex].replace('/', '');
found = language[options.lookupFromPathIndex].replace('/', '');
} else {
found = language[0].replace('/', '');
}
Expand Down Expand Up @@ -227,7 +227,7 @@
this.addDetector(localStorage);
this.addDetector(navigator$1);
this.addDetector(htmlTag);
this.addDetector(folder);
this.addDetector(path);
}
}, {
key: 'addDetector',
Expand Down
2 changes: 1 addition & 1 deletion i18nextBrowserLanguageDetector.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/browserLookups/folder.js → src/browserLookups/path.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export default {
name: 'folder',
name: 'path',

lookup(options) {
let found;
if (typeof window !== 'undefined') {
const language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
if (language instanceof Array) {
if (typeof options.lookupFromUrlIndex === 'number') {
found = language[options.lookupFromFolderIndex].replace('/', '');
found = language[options.lookupFromPathIndex].replace('/', '');
} else {
found = language[0].replace('/', '');
}
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import querystring from './browserLookups/querystring.js';
import localStorage from './browserLookups/localStorage.js';
import navigator from './browserLookups/navigator.js';
import htmlTag from './browserLookups/htmlTag.js';
import folder from './browserLookups/folder.js';
import path from './browserLookups/path.js';

function getDefaults() {
return {
Expand Down Expand Up @@ -39,7 +39,7 @@ class Browser {
this.addDetector(localStorage);
this.addDetector(navigator);
this.addDetector(htmlTag);
this.addDetector(folder);
this.addDetector(path);
}

addDetector(detector) {
Expand Down

0 comments on commit 04c2c37

Please sign in to comment.