The design calls for rendering all amounts with their currency symbol, but golang.org/x/text’s currency package always render the symbol in front, which is wrong in Catalan and Spanish, and a lot of other languages. Consulting the Internet, the most popular package for that is accounting[0], which is almost as useless because they confuse locale with the currency’s country of origin’s “usual locale” (e.g., en-US for USD), which is also wrong: in Catalan i need to write USD prices as "1.234,56 $" regardless of what Americans do. With accounting i have the recourse of initializing the struct that holds all the “locale” information, which is also wrong because i have to define the decimal and thousands separators, something that depends only on the locale, next to the currency’s precision, that is locale-independent. But, since all CLDR data from golang.org/x/text is inside an internal package, i can not access it and would need to define all that information myself, which defeats the purpose of using an external package. Since for now i only need the format pattern for currency, i just saved it into the database of available languages, that i do not expect to grow too much. [0]: https://github.com/leekchan/accounting
31 lines
762 B
PL/PgSQL
31 lines
762 B
PL/PgSQL
-- Deploy numerus:language to pg
|
|
-- requires: schema_numerus
|
|
|
|
begin;
|
|
|
|
set search_path to public;
|
|
|
|
create table language (
|
|
lang_tag text primary key check (length(lang_tag) < 36), -- RFC5646 recommends 35 at least
|
|
name text not null,
|
|
endonym text not null,
|
|
selectable boolean not null,
|
|
currency_pattern text not null
|
|
);
|
|
|
|
grant select on table language to guest;
|
|
grant select on table language to invoicer;
|
|
grant select on table language to admin;
|
|
grant select on table language to authenticator;
|
|
|
|
comment on table language is
|
|
'Languages/locales available in Numerus';
|
|
|
|
comment on column language.lang_tag is
|
|
'BCP-47 language tag';
|
|
|
|
comment on column language.selectable is
|
|
'Whether the language should be a option in a user-facing select control.';
|
|
|
|
commit;
|