src/third_party/mozjs/extract/js/src/builtin/intl/CommonFunctions.js
/**
 * Adds a Unicode extension subtag to a locale.
 *
 * Spec: ECMAScript Internationalization API Specification, 9.2.6.
 */
Adds a Unicode extension subtag to a locale.
Spec: ECMAScript Internationalization API Specification, 9.2.6.
Adds a Unicode extension subtag to a locale . Spec : ECMAScript Internationalization API Specification 9 . 2 . 6 .
function addUnicodeExtension(locale, extension) {
    assert(typeof locale === "string", "locale is a string value");
    assert(!callFunction(std_String_startsWith, locale, "x-"),
           "unexpected privateuse-only locale");
    assert(startOfUnicodeExtensions(locale) < 0,
           "Unicode extension subtag already present in locale");
    assert(typeof extension === "string", "extension is a string value");
    assert(callFunction(std_String_startsWith, extension, "-u-") &&
           getUnicodeExtensions("und" + extension) === extension,
           "extension is a Unicode extension subtag");
    var privateIndex = callFunction(std_String_indexOf, locale, "-x-");
    if (privateIndex === -1) {
        locale += extension;
    } else {
         var preExtension = callFunction(String_substring, locale, 0, privateIndex);
         var postExtension = callFunction(String_substring, locale, privateIndex);
         locale = preExtension + extension + postExtension;
    }
    assertIsValidAndCanonicalLanguageTag(locale, "locale after concatenation");
    return locale;
}
function addUnicodeExtension ( locale , extension ) { assert ( typeof locale === "string" , "locale is a string value" ) ; assert ( ! callFunction ( std_String_startsWith , locale , "x-" ) , "unexpected privateuse-only locale" ) ; assert ( startOfUnicodeExtensions ( locale ) < 0 , "Unicode extension subtag already present in locale" ) ; assert ( typeof extension === "string" , "extension is a string value" ) ; assert ( callFunction ( std_String_startsWith , extension , "-u-" ) && getUnicodeExtensions ( "und" + extension ) === extension , "extension is a Unicode extension subtag" ) ; var privateIndex = callFunction ( std_String_indexOf , locale , "-x-" ) ; if ( privateIndex === - 1 ) { locale += extension ; } else { var preExtension = callFunction ( String_substring , locale , 0 , privateIndex ) ; var postExtension = callFunction ( String_substring , locale , privateIndex ) ; locale = preExtension + extension + postExtension ; } assertIsValidAndCanonicalLanguageTag ( locale , "locale after concatenation" ) ; return locale ; }
Adds a Unicode extension subtag to a locale.
Adds a Unicode extension subtag to a locale .
// Step 9.a. // Steps 9.b-c. // Steps 9.d-e (Step 9.e is not required in this implementation, because we don't canonicalize // Unicode extension subtags).