From cf905894dcf3c4c9cdff7732f8d69c1e893bc1da Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 31 May 2020 05:37:02 +0200 Subject: [PATCH] word: two-letter language codes Match Wikipedia subdomains and common browser headers. --- tools/word.pg.sql | 6 +++--- word.plp | 4 ++-- writer.js | 4 ++-- writer.plp | 9 +++++---- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tools/word.pg.sql b/tools/word.pg.sql index 31a117e..55de8ec 100644 --- a/tools/word.pg.sql +++ b/tools/word.pg.sql @@ -1,7 +1,7 @@ CREATE TABLE word ( form text NOT NULL, alt text[], - lang text NOT NULL DEFAULT 'eng', + lang text NOT NULL DEFAULT 'en', cat integer REFERENCES word (id), ref integer REFERENCES word (id), prio smallint NOT NULL DEFAULT '1', @@ -16,9 +16,9 @@ CREATE TABLE word ( COMMENT ON COLUMN word.form IS 'preferred textual representation'; COMMENT ON COLUMN word.alt IS 'alternate forms with equivalent meaning'; -COMMENT ON COLUMN word.lang IS 'ISO 639-3 language code'; +COMMENT ON COLUMN word.lang IS 'ISO 639 language code matching wikipedia subdomain'; COMMENT ON COLUMN word.cat IS 'hierarchical classification'; -COMMENT ON COLUMN word.ref IS 'reference to equivalent eng translation'; +COMMENT ON COLUMN word.ref IS 'reference to equivalent en translation'; COMMENT ON COLUMN word.prio IS 'difficulty level or importance; lower values have precedence'; COMMENT ON COLUMN word.grade IS 'ascending hierarchical order, preceding default alphabetical'; COMMENT ON COLUMN word.cover IS 'highlight if selected'; diff --git a/word.plp b/word.plp index 5739731..508fd06 100644 --- a/word.plp +++ b/word.plp @@ -1,6 +1,6 @@ <(common.inc.plp)><: -my $wordlist = 'wordlist.eng.inc.pl'; +my $wordlist = 'wordlist.en.inc.pl'; my $limit = $get{v} // (exists $get{v} ? 4 : 3); Html({ @@ -90,7 +90,7 @@ sub showimg { $name = "$name" if $name =~ s/\?$//; $name = "
$name
"; - if ($imgname and -e ($img = "data/word/eng/$imgname.jpg")) { + if ($imgname and -e ($img = "data/word/en/$imgname.jpg")) { $name .= sprintf '%s', $img, $imgname; } return sprintf '%s', $hidden && !exists $get{v} && ' hidden', $name; diff --git a/writer.js b/writer.js index e9c81ef..80ba7b8 100644 --- a/writer.js +++ b/writer.js @@ -6,7 +6,7 @@ document.addEventListener('DOMContentLoaded', () => { wpbutton.append('Download'); wpbutton.onclick = () => { let wptitle = wpinput.value || document.getElementById('form').value; - let wplang = document.getElementById('lang').value.substr(0, 2); // crude iso-639-3→2 + let wplang = document.getElementById('lang').value; let wpapi = `https://${wplang}.wikipedia.org/w/api.php`; let wppage = wpapi+'?action=parse&format=json&origin=*&prop=text&page='+wptitle; fetch(wppage).then(res => res.json()).then(json => { @@ -37,7 +37,7 @@ document.addEventListener('DOMContentLoaded', () => { wpbutton.append('Visit'); wpbutton.onclick = () => { let wptitle = wpinput.value || document.getElementById('form').value; - let wplang = document.getElementById('lang').value.substr(0, 2); // crude iso-639-3→2 + let wplang = document.getElementById('lang').value; let wpurl = `https://${wplang}.wikipedia.org/wiki/${wptitle}`; window.open(wpurl, 'sheet-wikipedia').focus(); return false; diff --git a/writer.plp b/writer.plp index f954ba0..4da2705 100644 --- a/writer.plp +++ b/writer.plp @@ -106,9 +106,10 @@ my $db = eval { } or Abort('Database error', 501, $@); my %lang = ( - nld => ["\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}", 'dutch'], - eng => ["\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}", 'english'], - epo => ['★', 'esperanto'], + nl => ["\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}", 'nederlands'], + en => ["\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}", 'english'], + eo => ['★', 'esperanto'], + ru => ["\N{REGIONAL INDICATOR SYMBOL LETTER R}\N{REGIONAL INDICATOR SYMBOL LETTER U}", 'русский'], ); my @wordcols = pairkeys my %wordcol = ( @@ -277,7 +278,7 @@ package Shiar_Sheet::FormRow { sub imagepath { my ($row, $col) = @_; return "data/word/org/$row->{id}.jpg" if $col eq 'source'; - return "data/word/eng/$row->{form}.jpg" if $col eq 'thumb'; + return "data/word/en/$row->{form}.jpg" if $col eq 'thumb'; return; } } -- 2.30.0