Replace language with lang for consistency
This commit is contained in:
parent
5c911fc08d
commit
27b7252580
@ -4,7 +4,7 @@ use strings;
|
|||||||
|
|
||||||
// A parsed locale name.
|
// A parsed locale name.
|
||||||
export type locale = struct {
|
export type locale = struct {
|
||||||
language: str,
|
lang: str,
|
||||||
country: str,
|
country: str,
|
||||||
encoding: str,
|
encoding: str,
|
||||||
modifier: str,
|
modifier: str,
|
||||||
@ -25,7 +25,7 @@ export fn parse_locale(in: str) (locale | errors::invalid) = {
|
|||||||
let (in, country) = strings::rcut(in, "_");
|
let (in, country) = strings::rcut(in, "_");
|
||||||
if (strings::compare(in, "") == 0) return void: errors::invalid;
|
if (strings::compare(in, "") == 0) return void: errors::invalid;
|
||||||
return locale {
|
return locale {
|
||||||
language = in,
|
lang = in,
|
||||||
country = country,
|
country = country,
|
||||||
encoding = encoding,
|
encoding = encoding,
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
@ -34,7 +34,7 @@ export fn parse_locale(in: str) (locale | errors::invalid) = {
|
|||||||
|
|
||||||
// Formats a [[locale]]. The caller must free the return value.
|
// Formats a [[locale]]. The caller must free the return value.
|
||||||
export fn format_locale(local: locale) str = {
|
export fn format_locale(local: locale) str = {
|
||||||
let output = strings::dup(local.language);
|
let output = strings::dup(local.lang);
|
||||||
if (strings::compare(local.country, "") != 0) {
|
if (strings::compare(local.country, "") != 0) {
|
||||||
let new_output = strings::join("_", output, local.country);
|
let new_output = strings::join("_", output, local.country);
|
||||||
free(output);
|
free(output);
|
||||||
@ -55,7 +55,7 @@ export fn format_locale(local: locale) str = {
|
|||||||
|
|
||||||
// Checks if two [[locale]]s are equal.
|
// Checks if two [[locale]]s are equal.
|
||||||
export fn locale_equal(a: locale, b: locale) bool =
|
export fn locale_equal(a: locale, b: locale) bool =
|
||||||
strings::compare(a.language, b.language) == 0 &&
|
strings::compare(a.lang, b.lang ) == 0 &&
|
||||||
strings::compare(a.country, b.country ) == 0 &&
|
strings::compare(a.country, b.country ) == 0 &&
|
||||||
strings::compare(a.encoding, b.encoding) == 0 &&
|
strings::compare(a.encoding, b.encoding) == 0 &&
|
||||||
strings::compare(a.modifier, b.modifier) == 0;
|
strings::compare(a.modifier, b.modifier) == 0;
|
||||||
|
@ -7,8 +7,8 @@ use strings;
|
|||||||
case let local: locale => yield local;
|
case let local: locale => yield local;
|
||||||
case => abort("error");
|
case => abort("error");
|
||||||
};
|
};
|
||||||
fmt::printf("[{}]\n", local.language)!;
|
fmt::printf("[{}]\n", local.lang)!;
|
||||||
assert(strings::compare(local.language, "lang") == 0);
|
assert(strings::compare(local.lang, "lang") == 0);
|
||||||
fmt::printf("[{}]\n", local.country)!;
|
fmt::printf("[{}]\n", local.country)!;
|
||||||
assert(strings::compare(local.country, "COUNTRY") == 0);
|
assert(strings::compare(local.country, "COUNTRY") == 0);
|
||||||
fmt::printf("[{}]\n", local.encoding)!;
|
fmt::printf("[{}]\n", local.encoding)!;
|
||||||
@ -22,8 +22,8 @@ use strings;
|
|||||||
case let local: locale => yield local;
|
case let local: locale => yield local;
|
||||||
case => abort("error");
|
case => abort("error");
|
||||||
};
|
};
|
||||||
fmt::printf("[{}]\n", local.language)!;
|
fmt::printf("[{}]\n", local.lang)!;
|
||||||
assert(strings::compare(local.language, "lang") == 0);
|
assert(strings::compare(local.lang, "lang") == 0);
|
||||||
fmt::printf("[{}]\n", local.country)!;
|
fmt::printf("[{}]\n", local.country)!;
|
||||||
assert(strings::compare(local.country, "") == 0);
|
assert(strings::compare(local.country, "") == 0);
|
||||||
fmt::printf("[{}]\n", local.encoding)!;
|
fmt::printf("[{}]\n", local.encoding)!;
|
||||||
@ -37,8 +37,8 @@ use strings;
|
|||||||
case let local: locale => yield local;
|
case let local: locale => yield local;
|
||||||
case => abort("error");
|
case => abort("error");
|
||||||
};
|
};
|
||||||
fmt::printf("[{}]\n", local.language)!;
|
fmt::printf("[{}]\n", local.lang)!;
|
||||||
assert(strings::compare(local.language, "lang") == 0);
|
assert(strings::compare(local.lang, "lang") == 0);
|
||||||
fmt::printf("[{}]\n", local.country)!;
|
fmt::printf("[{}]\n", local.country)!;
|
||||||
assert(strings::compare(local.country, "") == 0);
|
assert(strings::compare(local.country, "") == 0);
|
||||||
fmt::printf("[{}]\n", local.encoding)!;
|
fmt::printf("[{}]\n", local.encoding)!;
|
||||||
@ -52,8 +52,8 @@ use strings;
|
|||||||
case let local: locale => yield local;
|
case let local: locale => yield local;
|
||||||
case => abort("error");
|
case => abort("error");
|
||||||
};
|
};
|
||||||
fmt::printf("[{}]\n", local.language)!;
|
fmt::printf("[{}]\n", local.lang)!;
|
||||||
assert(strings::compare(local.language, "lang") == 0);
|
assert(strings::compare(local.lang, "lang") == 0);
|
||||||
fmt::printf("[{}]\n", local.country)!;
|
fmt::printf("[{}]\n", local.country)!;
|
||||||
assert(strings::compare(local.country, "") == 0);
|
assert(strings::compare(local.country, "") == 0);
|
||||||
fmt::printf("[{}]\n", local.encoding)!;
|
fmt::printf("[{}]\n", local.encoding)!;
|
||||||
@ -71,7 +71,7 @@ use strings;
|
|||||||
|
|
||||||
@test fn format_locale_a() void = {
|
@test fn format_locale_a() void = {
|
||||||
let string = format_locale(locale {
|
let string = format_locale(locale {
|
||||||
language = "lang",
|
lang = "lang",
|
||||||
country = "COUNTRY",
|
country = "COUNTRY",
|
||||||
encoding = "ENCODING",
|
encoding = "ENCODING",
|
||||||
modifier = "MODIFIER",
|
modifier = "MODIFIER",
|
||||||
@ -83,7 +83,7 @@ use strings;
|
|||||||
|
|
||||||
@test fn format_locale_b() void = {
|
@test fn format_locale_b() void = {
|
||||||
let string = format_locale(locale {
|
let string = format_locale(locale {
|
||||||
language = "lang",
|
lang = "lang",
|
||||||
country = "COUNTRY",
|
country = "COUNTRY",
|
||||||
modifier = "MODIFIER",
|
modifier = "MODIFIER",
|
||||||
...
|
...
|
||||||
@ -95,7 +95,7 @@ use strings;
|
|||||||
|
|
||||||
@test fn format_locale_c() void = {
|
@test fn format_locale_c() void = {
|
||||||
let string = format_locale(locale {
|
let string = format_locale(locale {
|
||||||
language = "lang",
|
lang = "lang",
|
||||||
...
|
...
|
||||||
});
|
});
|
||||||
defer free(string);
|
defer free(string);
|
||||||
@ -105,37 +105,37 @@ use strings;
|
|||||||
|
|
||||||
@test fn locale_equal() void = {
|
@test fn locale_equal() void = {
|
||||||
assert(locale_equal(locale {
|
assert(locale_equal(locale {
|
||||||
language = "lang",
|
lang = "lang",
|
||||||
country = "COUNTRY",
|
country = "COUNTRY",
|
||||||
encoding = "ENCODING",
|
encoding = "ENCODING",
|
||||||
modifier = "MODIFIER",
|
modifier = "MODIFIER",
|
||||||
},
|
},
|
||||||
locale {
|
locale {
|
||||||
language = "lang",
|
lang = "lang",
|
||||||
country = "COUNTRY",
|
country = "COUNTRY",
|
||||||
encoding = "ENCODING",
|
encoding = "ENCODING",
|
||||||
modifier = "MODIFIER",
|
modifier = "MODIFIER",
|
||||||
}));
|
}));
|
||||||
assert(!locale_equal(locale {
|
assert(!locale_equal(locale {
|
||||||
language = "lang",
|
lang = "lang",
|
||||||
country = "COUNTRY",
|
country = "COUNTRY",
|
||||||
encoding = "ENCODING",
|
encoding = "ENCODING",
|
||||||
modifier = "MODIFIER",
|
modifier = "MODIFIER",
|
||||||
},
|
},
|
||||||
locale {
|
locale {
|
||||||
language = "foo",
|
lang = "foo",
|
||||||
country = "COUNTRY",
|
country = "COUNTRY",
|
||||||
encoding = "ENCODING",
|
encoding = "ENCODING",
|
||||||
modifier = "MODIFIER",
|
modifier = "MODIFIER",
|
||||||
}));
|
}));
|
||||||
assert(!locale_equal(locale {
|
assert(!locale_equal(locale {
|
||||||
language = "lang",
|
lang = "lang",
|
||||||
encoding = "ENCODING",
|
encoding = "ENCODING",
|
||||||
modifier = "MODIFIER",
|
modifier = "MODIFIER",
|
||||||
...
|
...
|
||||||
},
|
},
|
||||||
locale {
|
locale {
|
||||||
language = "lang",
|
lang = "lang",
|
||||||
country = "COUNTRY",
|
country = "COUNTRY",
|
||||||
encoding = "ENCODING",
|
encoding = "ENCODING",
|
||||||
...
|
...
|
||||||
|
Loading…
Reference in New Issue
Block a user