From 27b7252580a629147ced8cdbc6d8f4d45f15ce22 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 4 Oct 2024 13:26:37 -0400 Subject: [PATCH] Replace language with lang for consistency --- locale/locale.ha | 8 ++++---- locale/locale_test.ha | 34 +++++++++++++++++----------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/locale/locale.ha b/locale/locale.ha index bf39c8c..931104e 100644 --- a/locale/locale.ha +++ b/locale/locale.ha @@ -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; diff --git a/locale/locale_test.ha b/locale/locale_test.ha index ab8a743..d8afd9d 100644 --- a/locale/locale_test.ha +++ b/locale/locale_test.ha @@ -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", ...