Skip to content

Commit

Permalink
Merge pull request #3177 from Automattic/fix/3175-i18n-utils-not-retu…
Browse files Browse the repository at this point in the history
…rning-some-languages

i18nUtils: accept 3-letter locale slugs
  • Loading branch information
deBhal committed Feb 9, 2016
2 parents eff1b08 + 4c328ed commit fed9774
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions client/lib/i18n-utils/test/utils-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,10 @@ describe( 'i18n-utils', function() {
it( 'should return undefined when we lookup random words', function() {
expect( getLanguage( 'themes' ) ).to.equal( undefined );
} );

it( 'should return a language with a three letter country code', function() {
expect( getLanguage( 'ast' ).langSlug ).to.equal( 'ast' );
} );

} );
} );
4 changes: 2 additions & 2 deletions client/lib/i18n-utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import find from 'lodash/collection/find';
*/
import config from 'config';

const localeRegex = /^[A-Z]{2}$/i;
const localeWithRegionRegex = /^[A-Z]{2}-[A-Z]{2}$/i;
const localeRegex = /^[A-Z]{2,3}$/i;
const localeWithRegionRegex = /^[A-Z]{2,3}-[A-Z]{2,3}$/i;

function getPathParts( path ) {
// Remove trailing slash then split. If there is a trailing slash,
Expand Down

0 comments on commit fed9774

Please sign in to comment.