mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-06 01:56:40 +00:00
add locales
This commit is contained in:
parent
196895d3db
commit
88b033425c
3 changed files with 91 additions and 3 deletions
82
src/data.ts
Normal file
82
src/data.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
||||||
|
export const locales = {
|
||||||
|
Afrikaans: "Hallo, wêreld!",
|
||||||
|
Albanian: "Pershëndetje Botë",
|
||||||
|
Arabic: "أهلاً بالعالم (Ahlan bil 'Alam)",
|
||||||
|
Armenian: "Բարե՛ւ, աշխարհ։ (barev ash'kharh)",
|
||||||
|
Azeri: "Salam Dünya",
|
||||||
|
Czech: "Ahoj Světe!",
|
||||||
|
BasqueEuskara: "Kaixo mundua!",
|
||||||
|
Belarusian: "Прывітанне свет (Pryvitannie sviet)",
|
||||||
|
Bemba: "Shani Mwechalo!",
|
||||||
|
Bengali: "Shagatam Prithivi!",
|
||||||
|
Bosnian: "Zdravo Svijete!",
|
||||||
|
Bulgarian: "Здравей, свят! (Zdrav'ei svi'at)",
|
||||||
|
Cambodian: "ជំរាបសួរ ពិភពលោក (chomreabsuor piphoplok)",
|
||||||
|
Catalan: "Hola món!",
|
||||||
|
Chinese: "你好世界 (nǐ hǎo shì jiè)",
|
||||||
|
Cherokee: "ᎣᏏᏲ ᎡᎶᎯ (O-si-yo E-lo-hi)",
|
||||||
|
ChinookWawa: "Klahowya Hayas Klaska",
|
||||||
|
Croatian: "Bok Svijete!",
|
||||||
|
Danish: "Hej, Verden!",
|
||||||
|
Dutch: "Hallo, wereld!",
|
||||||
|
English: "Hello World!",
|
||||||
|
Esperanto: "Saluton mondo!",
|
||||||
|
Estonian: "Tere maailm!",
|
||||||
|
Finnish: "Hei maailma!",
|
||||||
|
French: "Salut le Monde!",
|
||||||
|
Frisian: "Hallo, wrâld!",
|
||||||
|
Galician: "Ola mundo!",
|
||||||
|
German: "Hallo Welt!",
|
||||||
|
Greek: "Γεια σου κόσμε! (Geia soy kosme)",
|
||||||
|
Hawaiian: "Aloha Honua",
|
||||||
|
Hebrew: "Shalom Olam",
|
||||||
|
Hindi: "नमस्ते दुनिया (namaste duniya)",
|
||||||
|
Hmong: "Nyob zoo ntiaj teb.",
|
||||||
|
Hungarian: "Helló világ!",
|
||||||
|
Icelandic: "Halló heimur!",
|
||||||
|
Igbo: "Ndewo Ụwa",
|
||||||
|
Indonesian: "Halo Dunia!",
|
||||||
|
Irish: "Dia dhaoibh, a dhomhain!",
|
||||||
|
Italian: "Ciao Mondo!",
|
||||||
|
Japanese: "こんにちは、 世界! (konnichiwa sekai)",
|
||||||
|
Kannada: "ಹಲೋ ವರ್ಲ್ಡ್ (Halō varlḍ)",
|
||||||
|
Kiswahili: "Habari dunia!",
|
||||||
|
Kikuyu: "Niatia thi!",
|
||||||
|
Klingon: "nuqneH",
|
||||||
|
Korean: "반갑다 세상아 (bangabda, sesangah)",
|
||||||
|
Lao: "ສະບາຍດີ,ໂລກ (sabaidi olk)",
|
||||||
|
Latin: "AVE MVNDE (ave munde)",
|
||||||
|
Latvian: "Sveika, Pasaule!",
|
||||||
|
Lithuanian: "Sveikas, Pasauli",
|
||||||
|
Lojban: "coi li terdi",
|
||||||
|
Luxembourgish: "Moien Welt!",
|
||||||
|
Malagasy: "Manao ahoana ry tany!",
|
||||||
|
Malayalam: "Namaskaram, lokame",
|
||||||
|
Maltese: "Merhba lid-dinja",
|
||||||
|
Norwegian: "Hallo verden!",
|
||||||
|
Persian: "!سلام دنیا (Salaam Donyaa!)",
|
||||||
|
Polish: "Witaj świecie!",
|
||||||
|
Portuguese: "Olá, mundo!",
|
||||||
|
Punjabi: "ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ (Sati srī akāla duni'ā)",
|
||||||
|
Romanian: "Salut lume!",
|
||||||
|
Russian: "Здравствуй, мир! (Zdra'vstvuj mi'r)",
|
||||||
|
Scots: "Gaelic Halò, a Shaoghail!",
|
||||||
|
Serbian: "Zdravo Svete!",
|
||||||
|
Slovak: "Ahoj, svet!",
|
||||||
|
Slovenian: "Pozdravljen svet!",
|
||||||
|
Spanish: "¡Hola mundo!",
|
||||||
|
Swedish: "Hallå världen!",
|
||||||
|
Tagalog: "Kamusta mundo!",
|
||||||
|
Tamil: "ஹலோ உலகம் (Halō ulakam)",
|
||||||
|
Telugu: "హలో వరల్డ్ (Halō varalḍ)",
|
||||||
|
Thai: "สวัสดีโลก! (sawadee lok)",
|
||||||
|
Turkish: "Merhaba Dünya!",
|
||||||
|
Ukrainian: "Привiт, свiте! (Pryvi't svi'te)",
|
||||||
|
Urdu: "ہیلو دنیا والو",
|
||||||
|
Vietnamese: "Xin chào thế giới",
|
||||||
|
Welsh: "S'mae byd!",
|
||||||
|
Yiddish: "העלא וועלט (hela velt)",
|
||||||
|
Zulu: "Sawubona Mhlaba",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const localesSize = Object.keys(locales).length;
|
||||||
|
|
@ -4,6 +4,7 @@ import {
|
||||||
} from "https://deno.land/std@0.87.0/testing/asserts.ts";
|
} from "https://deno.land/std@0.87.0/testing/asserts.ts";
|
||||||
import { sayHello } from "./index.ts";
|
import { sayHello } from "./index.ts";
|
||||||
import { ValidationError } from "./validation.ts";
|
import { ValidationError } from "./validation.ts";
|
||||||
|
import { localesSize } from "./data.ts";
|
||||||
|
|
||||||
Deno.test("Hello test", () => {
|
Deno.test("Hello test", () => {
|
||||||
const actual = sayHello();
|
const actual = sayHello();
|
||||||
|
|
@ -25,6 +26,10 @@ Deno.test("Hello fails for non strictly positive values", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Deno.test("Hello fails for too large values", () => {
|
Deno.test("Hello fails for too large values", () => {
|
||||||
const id = 666;
|
const id = localesSize;
|
||||||
assertThrows(() => sayHello(id), ValidationError, "Invalid index: 666");
|
assertThrows(
|
||||||
|
() => sayHello(id),
|
||||||
|
ValidationError,
|
||||||
|
`Invalid index: ${localesSize}`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ValidationError } from "./validation.ts";
|
import { ValidationError } from "./validation.ts";
|
||||||
|
import { localesSize } from "./data.ts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the iconic Hello, World
|
* Display the iconic Hello, World
|
||||||
|
|
@ -10,4 +11,4 @@ export const sayHello = (id?: number) => {
|
||||||
return (id === 5) ? "Bonjour le monde" : "Hello, World!";
|
return (id === 5) ? "Bonjour le monde" : "Hello, World!";
|
||||||
};
|
};
|
||||||
|
|
||||||
const idInValidRange = (id: number) => id < 1 || id > 100;
|
const idInValidRange = (id: number) => id < 1 || id >= localesSize;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue