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.
|
||||
export type locale = struct {
|
||||
language: str,
|
||||
lang: str,
|
||||
country: str,
|
||||
encoding: str,
|
||||
modifier: str,
|
||||
@ -25,7 +25,7 @@ export fn parse_locale(in: str) (locale | errors::invalid) = {
|
||||
let (in, country) = strings::rcut(in, "_");
|
||||
if (strings::compare(in, "") == 0) return void: errors::invalid;
|
||||
return locale {
|
||||
language = in,
|
||||
lang = in,
|
||||
country = country,
|
||||
encoding = encoding,
|
||||
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.
|
||||
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) {
|
||||
let new_output = strings::join("_", output, local.country);
|
||||
free(output);
|
||||
@ -55,7 +55,7 @@ export fn format_locale(local: locale) str = {
|
||||
|
||||
// Checks if two [[locale]]s are equal.
|
||||
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.encoding, b.encoding) == 0 &&
|
||||
strings::compare(a.modifier, b.modifier) == 0;
|
||||
|
@ -7,8 +7,8 @@ use strings;
|
||||
case let local: locale => yield local;
|
||||
case => abort("error");
|
||||
};
|
||||
fmt::printf("[{}]\n", local.language)!;
|
||||
assert(strings::compare(local.language, "lang") == 0);
|
||||
fmt::printf("[{}]\n", local.lang)!;
|
||||
assert(strings::compare(local.lang, "lang") == 0);
|
||||
fmt::printf("[{}]\n", local.country)!;
|
||||
assert(strings::compare(local.country, "COUNTRY") == 0);
|
||||
fmt::printf("[{}]\n", local.encoding)!;
|
||||
@ -22,8 +22,8 @@ use strings;
|
||||
case let local: locale => yield local;
|
||||
case => abort("error");
|
||||
};
|
||||
fmt::printf("[{}]\n", local.language)!;
|
||||
assert(strings::compare(local.language, "lang") == 0);
|
||||
fmt::printf("[{}]\n", local.lang)!;
|
||||
assert(strings::compare(local.lang, "lang") == 0);
|
||||
fmt::printf("[{}]\n", local.country)!;
|
||||
assert(strings::compare(local.country, "") == 0);
|
||||
fmt::printf("[{}]\n", local.encoding)!;
|
||||
@ -37,8 +37,8 @@ use strings;
|
||||
case let local: locale => yield local;
|
||||
case => abort("error");
|
||||
};
|
||||
fmt::printf("[{}]\n", local.language)!;
|
||||
assert(strings::compare(local.language, "lang") == 0);
|
||||
fmt::printf("[{}]\n", local.lang)!;
|
||||
assert(strings::compare(local.lang, "lang") == 0);
|
||||
fmt::printf("[{}]\n", local.country)!;
|
||||
assert(strings::compare(local.country, "") == 0);
|
||||
fmt::printf("[{}]\n", local.encoding)!;
|
||||
@ -52,8 +52,8 @@ use strings;
|
||||
case let local: locale => yield local;
|
||||
case => abort("error");
|
||||
};
|
||||
fmt::printf("[{}]\n", local.language)!;
|
||||
assert(strings::compare(local.language, "lang") == 0);
|
||||
fmt::printf("[{}]\n", local.lang)!;
|
||||
assert(strings::compare(local.lang, "lang") == 0);
|
||||
fmt::printf("[{}]\n", local.country)!;
|
||||
assert(strings::compare(local.country, "") == 0);
|
||||
fmt::printf("[{}]\n", local.encoding)!;
|
||||
@ -71,7 +71,7 @@ use strings;
|
||||
|
||||
@test fn format_locale_a() void = {
|
||||
let string = format_locale(locale {
|
||||
language = "lang",
|
||||
lang = "lang",
|
||||
country = "COUNTRY",
|
||||
encoding = "ENCODING",
|
||||
modifier = "MODIFIER",
|
||||
@ -83,7 +83,7 @@ use strings;
|
||||
|
||||
@test fn format_locale_b() void = {
|
||||
let string = format_locale(locale {
|
||||
language = "lang",
|
||||
lang = "lang",
|
||||
country = "COUNTRY",
|
||||
modifier = "MODIFIER",
|
||||
...
|
||||
@ -95,7 +95,7 @@ use strings;
|
||||
|
||||
@test fn format_locale_c() void = {
|
||||
let string = format_locale(locale {
|
||||
language = "lang",
|
||||
lang = "lang",
|
||||
...
|
||||
});
|
||||
defer free(string);
|
||||
@ -105,37 +105,37 @@ use strings;
|
||||
|
||||
@test fn locale_equal() void = {
|
||||
assert(locale_equal(locale {
|
||||
language = "lang",
|
||||
lang = "lang",
|
||||
country = "COUNTRY",
|
||||
encoding = "ENCODING",
|
||||
modifier = "MODIFIER",
|
||||
},
|
||||
locale {
|
||||
language = "lang",
|
||||
lang = "lang",
|
||||
country = "COUNTRY",
|
||||
encoding = "ENCODING",
|
||||
modifier = "MODIFIER",
|
||||
}));
|
||||
assert(!locale_equal(locale {
|
||||
language = "lang",
|
||||
lang = "lang",
|
||||
country = "COUNTRY",
|
||||
encoding = "ENCODING",
|
||||
modifier = "MODIFIER",
|
||||
},
|
||||
locale {
|
||||
language = "foo",
|
||||
lang = "foo",
|
||||
country = "COUNTRY",
|
||||
encoding = "ENCODING",
|
||||
modifier = "MODIFIER",
|
||||
}));
|
||||
assert(!locale_equal(locale {
|
||||
language = "lang",
|
||||
lang = "lang",
|
||||
encoding = "ENCODING",
|
||||
modifier = "MODIFIER",
|
||||
...
|
||||
},
|
||||
locale {
|
||||
language = "lang",
|
||||
lang = "lang",
|
||||
country = "COUNTRY",
|
||||
encoding = "ENCODING",
|
||||
...
|
||||
|
Loading…
Reference in New Issue
Block a user