web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

commit ab91606c5cd298907174faf8d06533021b08b2a6
parent 19eeaa2f75f7f68d5042aade9e94894abd2144b0
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Fri, 23 May 2025 02:43:05 +0000

locales: add/edit `en` messages. add json import assertions

Diffstat:
Mlocales/.gitignore | 1+
Mlocales/package.json | 56++++++++++++++++++++++++++++++--------------------------
Mlocales/src/index.ts | 25++++++++++++++++++++-----
Mlocales/src/messages/en/common.json | 15+++++++++++++++
Mlocales/src/messages/en/countries.json | 498++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mlocales/src/messages/en/icu.json | 1+
Mlocales/tsconfig.json | 52+++++++++++++++++++++++++---------------------------
Dlocales/tsup.config.ts | 11-----------
8 files changed, 341 insertions(+), 318 deletions(-)

diff --git a/locales/.gitignore b/locales/.gitignore @@ -45,3 +45,4 @@ notes*.txt notes*.md git-diff.txt justfile +*.tsbuildinfo* diff --git a/locales/package.json b/locales/package.json @@ -1,29 +1,33 @@ { - "name": "@radroots/locales", - "version": "0.0.0", - "private": true, - "license": "GPLv3", - "type": "module", - "main": "dist/index.js", - "module": "dist/index.js", - "types": "dist/index.d.ts", - "exports": { - ".": { - "import": "./dist/index.js", - "require": "./dist/index.cjs" + "name": "@radroots/locales", + "version": "0.0.1", + "private": true, + "license": "GPLv3", + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "files": [ + "dist" + ], + "exports": { + ".": { + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + } + }, + "scripts": { + "prebuild": "npm run clean", + "build": "tsc", + "clean": "rimraf dist && rimraf tsconfig.tsbuildinfo", + "lint": "eslint 'src/**/*.{ts,tsx}'", + "format": "prettier --write \"src/**/*.{ts,tsx}\"", + "test": "jest" + }, + "devDependencies": { + "@types/node": "^22.15.3", + "typescript": "5.8.2" + }, + "publishConfig": { + "access": "public" } - }, - "scripts": { - "build": "tsup", - "dev": "tsup --watch", - "watch": "tsc -w" - }, - "devDependencies": { - "@types/node": "^22.13.1", - "tsup": "^6.2.3", - "typescript": "^5.3.3" - }, - "publishConfig": { - "access": "public" - } } \ No newline at end of file diff --git a/locales/src/index.ts b/locales/src/index.ts @@ -1,6 +1,22 @@ -import iso3166_2 from "./data/iso3166_2.json"; -import iso639_1 from "./data/iso639_1.json"; -import locales from "./data/locales.json"; +import iso3166_2 from "./data/iso3166_2.json" assert { type: "json" }; +import iso639_1 from "./data/iso639_1.json" assert { type: "json" }; +import locales from "./data/locales.json" assert { type: "json" }; +export { iso3166_2, iso639_1, locales }; export const locales_default = [`en`] as const; -export { iso3166_2, iso639_1, locales }; -\ No newline at end of file +export type Locales = typeof locales_default[number]; +export const locales_set = new Set<string>(locales_default); + +export const get_locales_undef = (val?: string): Locales | undefined => { + switch (val) { + case `en`: + return val; + default: + return undefined; + } +}; + +export const get_locales = (val?: string, fallback?: Locales): Locales => { + const loc = get_locales_undef(val); + return loc || fallback || `en`; +}; diff --git a/locales/src/messages/en/common.json b/locales/src/messages/en/common.json @@ -1,4 +1,19 @@ { + "reply": "Reply", + "follow": "Follow", + "reactions": "Reactions", + "all_sellers": "All Sellers", + "recommended": "Recommended", + "recent": "Recent", + "retrieved": "Retrieved", + "found_on": "Found on", + "by": "By", + "welcome": "Welcome", + "rss": "RSS", + "subscribe": "Subscribe", + "about": "About", + "events": "Events", + "catalog": "Catalog", "about_us": "About us", "accept": "Accept", "account_type": "Account type", diff --git a/locales/src/messages/en/countries.json b/locales/src/messages/en/countries.json @@ -1,251 +1,251 @@ { - "AD": "Andorra", - "AE": "United Arab Emirates", - "AF": "Afghanistan", - "AG": "Antigua and Barbuda", - "AI": "Anguilla", - "AL": "Albania", - "AM": "Armenia", - "AO": "Angola", - "AQ": "Antarctica", - "AR": "Argentina", - "AS": "American Samoa", - "AT": "Austria", - "AU": "Australia", - "AW": "Aruba", - "AX": "Åland Islands", - "AZ": "Azerbaijan", - "BA": "Bosnia and Herzegovina", - "BB": "Barbados", - "BD": "Bangladesh", - "BE": "Belgium", - "BF": "Burkina Faso", - "BG": "Bulgaria", - "BH": "Bahrain", - "BI": "Burundi", - "BJ": "Benin", - "BL": "Saint Barthélemy", - "BM": "Bermuda", - "BN": "Brunei Darussalam", - "BO": "Bolivia", - "BQ": "Bonaire, Sint Eustatius and Saba", - "BR": "Brazil", - "BS": "Bahamas", - "BT": "Bhutan", - "BV": "Bouvet Island", - "BW": "Botswana", - "BY": "Belarus", - "BZ": "Belize", - "CA": "Canada", - "CC": "Cocos (Keeling) Islands", - "CD": "Democratic Republic of the Congo", - "CF": "Central African Republic", - "CG": "Congo", - "CH": "Switzerland", - "CI": "Côte d'Ivoire", - "CK": "Cook Islands", - "CL": "Chile", - "CM": "Cameroon", - "CN": "China", - "CO": "Colombia", - "CR": "Costa Rica", - "CU": "Cuba", - "CV": "Cabo Verde", - "CW": "Curaçao", - "CX": "Christmas Island", - "CY": "Cyprus", - "CZ": "Czechia", - "DE": "Germany", - "DJ": "Djibouti", - "DK": "Denmark", - "DM": "Dominica", - "DO": "Dominican Republic", - "DZ": "Algeria", - "EC": "Ecuador", - "EE": "Estonia", - "EG": "Egypt", - "EH": "Western Sahara", - "ER": "Eritrea", - "ES": "Spain", - "ET": "Ethiopia", - "FI": "Finland", - "FJ": "Fiji", - "FK": "Malvinas Islands", - "FM": "Federated States of Micronesia", - "FO": "Faroe Islands", - "FR": "France", - "GA": "Gabon", - "GB": "United Kingdom of Great Britain and Northern Ireland", - "GD": "Grenada", - "GE": "Georgia", - "GF": "French Guiana", - "GG": "Guernsey", - "GH": "Ghana", - "GI": "Gibraltar", - "GL": "Greenland", - "GM": "Gambia", - "GN": "Guinea", - "GP": "Guadeloupe", - "GQ": "Equatorial Guinea", - "GR": "Greece", - "GS": "South Georgia and the South Sandwich Islands", - "GT": "Guatemala", - "GU": "Guam", - "GW": "Guinea-Bissau", - "GY": "Guyana", - "HK": "Hong Kong", - "HM": "Heard Island and McDonald Islands", - "HN": "Honduras", - "HR": "Croatia", - "HT": "Haiti", - "HU": "Hungary", - "ID": "Indonesia", - "IE": "Ireland", - "IL": "Israel", - "IM": "Isle of Man", - "IN": "India", - "IO": "British Indian Ocean Territory", - "IQ": "Iraq", - "IR": "Iran", - "IS": "Iceland", - "IT": "Italy", - "JE": "Jersey", - "JM": "Jamaica", - "JO": "Jordan", - "JP": "Japan", - "KE": "Kenya", - "KG": "Kyrgyzstan", - "KH": "Cambodia", - "KI": "Kiribati", - "KM": "Comoros", - "KN": "Saint Kitts and Nevis", - "KP": "Democratic People's Republic of Korea", - "KR": "Republic of Korea", - "KW": "Kuwait", - "KY": "Cayman Islands", - "KZ": "Kazakhstan", - "LA": "Lao People's Democratic Republic", - "LB": "Lebanon", - "LC": "Saint Lucia", - "LI": "Liechtenstein", - "LK": "Sri Lanka", - "LR": "Liberia", - "LS": "Lesotho", - "LT": "Lithuania", - "LU": "Luxembourg", - "LV": "Latvia", - "LY": "Libya", - "MA": "Morocco", - "MC": "Monaco", - "MD": "Moldova", - "ME": "Montenegro", - "MF": "Saint Martin", - "MG": "Madagascar", - "MH": "Marshall Islands", - "MK": "North Macedonia", - "ML": "Mali", - "MM": "Myanmar", - "MN": "Mongolia", - "MO": "Macao", - "MP": "Northern Mariana Islands", - "MQ": "Martinique", - "MR": "Mauritania", - "MS": "Montserrat", - "MT": "Malta", - "MU": "Mauritius", - "MV": "Maldives", - "MW": "Malawi", - "MX": "Mexico", - "MY": "Malaysia", - "MZ": "Mozambique", - "NA": "Namibia", - "NC": "New Caledonia", - "NE": "Niger", - "NF": "Norfolk Island", - "NG": "Nigeria", - "NI": "Nicaragua", - "NL": "Netherlands", - "NO": "Norway", - "NP": "Nepal", - "NR": "Nauru", - "NU": "Niue", - "NZ": "New Zealand", - "OM": "Oman", - "PA": "Panama", - "PE": "Peru", - "PF": "French Polynesia", - "PG": "Papua New Guinea", - "PH": "Philippines", - "PK": "Pakistan", - "PL": "Poland", - "PM": "Saint Pierre and Miquelon", - "PN": "Pitcairn", - "PR": "Puerto Rico", - "PS": "Palestine", - "PT": "Portugal", - "PW": "Palau", - "PY": "Paraguay", - "QA": "Qatar", - "RE": "Réunion", - "RO": "Romania", - "RS": "Serbia", - "RU": "Russian Federation", - "RW": "Rwanda", - "SA": "Saudi Arabia", - "SB": "Solomon Islands", - "SC": "Seychelles", - "SD": "Sudan", - "SE": "Sweden", - "SG": "Singapore", - "SH": "Saint Helena, Ascension and Tristan da Cunha", - "SI": "Slovenia", - "SJ": "Svalbard and Jan Mayen", - "SK": "Slovakia", - "SL": "Sierra Leone", - "SM": "San Marino", - "SN": "Senegal", - "SO": "Somalia", - "SR": "Suriname", - "SS": "South Sudan", - "ST": "Sao Tome and Principe", - "SV": "El Salvador", - "SX": "Sint Maarten", - "SY": "Syrian Arab Republic", - "SZ": "Eswatini", - "TC": "Turks and Caicos Islands", - "TD": "Chad", - "TF": "French Southern Territories", - "TG": "Togo", - "TH": "Thailand", - "TJ": "Tajikistan", - "TK": "Tokelau", - "TL": "Timor-Leste", - "TM": "Turkmenistan", - "TN": "Tunisia", - "TO": "Tonga", - "TR": "Türkiye", - "TT": "Trinidad and Tobago", - "TV": "Tuvalu", - "TW": "Taiwan", - "TZ": "Tanzania", - "UA": "Ukraine", - "UG": "Uganda", - "UM": "United States Minor Outlying Islands", - "US": "United States of America", - "UY": "Uruguay", - "UZ": "Uzbekistan", - "VA": "Holy See", - "VC": "Saint Vincent and the Grenadines", - "VE": "Venezuela", - "VG": "British Virgin Islands", - "VI": "U.S. Virgin Islands", - "VN": "Viet Nam", - "VU": "Vanuatu", - "WF": "Wallis and Futuna", - "WS": "Samoa", - "YE": "Yemen", - "YT": "Mayotte", - "ZA": "South Africa", - "ZM": "Zambia", - "ZW": "Zimbabwe" + "ad": "Andorra", + "ae": "United Arab Emirates", + "af": "Afghanistan", + "ag": "Antigua and Barbuda", + "ai": "Anguilla", + "al": "Albania", + "am": "Armenia", + "ao": "Angola", + "aq": "Antarctica", + "ar": "Argentina", + "as": "American Samoa", + "at": "Austria", + "au": "Australia", + "aw": "Aruba", + "ax": "Åland Islands", + "az": "Azerbaijan", + "ba": "Bosnia and Herzegovina", + "bb": "Barbados", + "bd": "Bangladesh", + "be": "Belgium", + "bf": "Burkina Faso", + "bg": "Bulgaria", + "bh": "Bahrain", + "bi": "Burundi", + "bj": "Benin", + "bl": "Saint Barthélemy", + "bm": "Bermuda", + "bn": "Brunei Darussalam", + "bo": "Bolivia", + "bq": "Bonaire, Sint Eustatius and Saba", + "br": "Brazil", + "bs": "Bahamas", + "bt": "Bhutan", + "bv": "Bouvet Island", + "bw": "Botswana", + "by": "Belarus", + "bz": "Belize", + "ca": "Canada", + "cc": "Cocos (Keeling) Islands", + "cd": "Democratic Republic of the Congo", + "cf": "Central African Republic", + "cg": "Congo", + "ch": "Switzerland", + "ci": "Côte d'Ivoire", + "ck": "Cook Islands", + "cl": "Chile", + "cm": "Cameroon", + "cn": "China", + "co": "Colombia", + "cr": "Costa Rica", + "cu": "Cuba", + "cv": "Cabo Verde", + "cw": "Curaçao", + "cx": "Christmas Island", + "cy": "Cyprus", + "cz": "Czechia", + "de": "Germany", + "dj": "Djibouti", + "dk": "Denmark", + "dm": "Dominica", + "do": "Dominican Republic", + "dz": "Algeria", + "ec": "Ecuador", + "ee": "Estonia", + "eg": "Egypt", + "eh": "Western Sahara", + "er": "Eritrea", + "es": "Spain", + "et": "Ethiopia", + "fi": "Finland", + "fj": "Fiji", + "fk": "Malvinas Islands", + "fm": "Federated States of Micronesia", + "fo": "Faroe Islands", + "fr": "France", + "ga": "Gabon", + "gb": "United Kingdom of Great Britain and Northern Ireland", + "gd": "Grenada", + "ge": "Georgia", + "gf": "French Guiana", + "gg": "Guernsey", + "gh": "Ghana", + "gi": "Gibraltar", + "gl": "Greenland", + "gm": "Gambia", + "gn": "Guinea", + "gp": "Guadeloupe", + "gq": "Equatorial Guinea", + "gr": "Greece", + "gs": "South Georgia and the South Sandwich Islands", + "gt": "Guatemala", + "gu": "Guam", + "gw": "Guinea-Bissau", + "gy": "Guyana", + "hk": "Hong Kong", + "hm": "Heard Island and McDonald Islands", + "hn": "Honduras", + "hr": "Croatia", + "ht": "Haiti", + "hu": "Hungary", + "id": "Indonesia", + "ie": "Ireland", + "il": "Israel", + "im": "Isle of Man", + "in": "India", + "io": "British Indian Ocean Territory", + "iq": "Iraq", + "ir": "Iran", + "is": "Iceland", + "it": "Italy", + "je": "Jersey", + "jm": "Jamaica", + "jo": "Jordan", + "jp": "Japan", + "ke": "Kenya", + "kg": "Kyrgyzstan", + "kh": "Cambodia", + "ki": "Kiribati", + "km": "Comoros", + "kn": "Saint Kitts and Nevis", + "kp": "Democratic People's Republic of Korea", + "kr": "Republic of Korea", + "kw": "Kuwait", + "ky": "Cayman Islands", + "kz": "Kazakhstan", + "la": "Lao People's Democratic Republic", + "lb": "Lebanon", + "lc": "Saint Lucia", + "li": "Liechtenstein", + "lk": "Sri Lanka", + "lr": "Liberia", + "ls": "Lesotho", + "lt": "Lithuania", + "lu": "Luxembourg", + "lv": "Latvia", + "ly": "Libya", + "ma": "Morocco", + "mc": "Monaco", + "md": "Moldova", + "me": "Montenegro", + "mf": "Saint Martin", + "mg": "Madagascar", + "mh": "Marshall Islands", + "mk": "North Macedonia", + "ml": "Mali", + "mm": "Myanmar", + "mn": "Mongolia", + "mo": "Macao", + "mp": "Northern Mariana Islands", + "mq": "Martinique", + "mr": "Mauritania", + "ms": "Montserrat", + "mt": "Malta", + "mu": "Mauritius", + "mv": "Maldives", + "mw": "Malawi", + "mx": "Mexico", + "my": "Malaysia", + "mz": "Mozambique", + "na": "Namibia", + "nc": "New Caledonia", + "ne": "Niger", + "nf": "Norfolk Island", + "ng": "Nigeria", + "ni": "Nicaragua", + "nl": "Netherlands", + "no": "Norway", + "np": "Nepal", + "nr": "Nauru", + "nu": "Niue", + "nz": "New Zealand", + "om": "Oman", + "pa": "Panama", + "pe": "Peru", + "pf": "French Polynesia", + "pg": "Papua New Guinea", + "ph": "Philippines", + "pk": "Pakistan", + "pl": "Poland", + "pm": "Saint Pierre and Miquelon", + "pn": "Pitcairn", + "pr": "Puerto Rico", + "ps": "Palestine", + "pt": "Portugal", + "pw": "Palau", + "py": "Paraguay", + "qa": "Qatar", + "re": "Réunion", + "ro": "Romania", + "rs": "Serbia", + "ru": "Russian Federation", + "rw": "Rwanda", + "sa": "Saudi Arabia", + "sb": "Solomon Islands", + "sc": "Seychelles", + "sd": "Sudan", + "se": "Sweden", + "sg": "Singapore", + "sh": "Saint Helena, Ascension and Tristan da Cunha", + "si": "Slovenia", + "sj": "Svalbard and Jan Mayen", + "sk": "Slovakia", + "sl": "Sierra Leone", + "sm": "San Marino", + "sn": "Senegal", + "so": "Somalia", + "sr": "Suriname", + "ss": "South Sudan", + "st": "Sao Tome and Principe", + "sv": "El Salvador", + "sx": "Sint Maarten", + "sy": "Syrian Arab Republic", + "sz": "Eswatini", + "tc": "Turks and Caicos Islands", + "td": "Chad", + "tf": "French Southern Territories", + "tg": "Togo", + "th": "Thailand", + "tj": "Tajikistan", + "tk": "Tokelau", + "tl": "Timor-Leste", + "tm": "Turkmenistan", + "tn": "Tunisia", + "to": "Tonga", + "tr": "Türkiye", + "tt": "Trinidad and Tobago", + "tv": "Tuvalu", + "tw": "Taiwan", + "tz": "Tanzania", + "ua": "Ukraine", + "ug": "Uganda", + "um": "United States Minor Outlying Islands", + "us": "United States of America", + "uy": "Uruguay", + "uz": "Uzbekistan", + "va": "Holy See", + "vc": "Saint Vincent and the Grenadines", + "ve": "Venezuela", + "vg": "British Virgin Islands", + "vi": "U.S. Virgin Islands", + "vn": "Viet Nam", + "vu": "Vanuatu", + "wf": "Wallis and Futuna", + "ws": "Samoa", + "ye": "Yemen", + "yt": "Mayotte", + "za": "South Africa", + "zm": "Zambia", + "zw": "Zimbabwe" } \ No newline at end of file diff --git a/locales/src/messages/en/icu.json b/locales/src/messages/en/icu.json @@ -1,4 +1,5 @@ { + "by_*": "By {{value}}", "*_information": "{{value}} information", "*_name": "{{value}} name", "*_price": "{{value}} price", diff --git a/locales/tsconfig.json b/locales/tsconfig.json @@ -1,29 +1,27 @@ { "compilerOptions": { - "strict": true, - "target": "es2021", - "lib": [ - "es2021", - "dom" - ], - "module": "ESNext", - "moduleResolution": "node", - "declaration": true, - "declarationMap": true, - "outDir": "./dist", - "esModuleInterop": true, - "skipLibCheck": true, - "baseUrl": ".", - "resolveJsonModule": true, - "paths": { - "$root": ["src/index.js"] - } + "plugins": [{ "transform": "tsc-alias/transform" }], + "target": "ES2022", + "module": "ESNext", + "lib": ["ES2022"], + "moduleResolution": "node", + "moduleDetection": "force", + "rootDir": "./src", + "outDir": "./dist", + "baseUrl": "./", + "declaration": true, + "declarationMap": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "strict": true, + "sourceMap": true, + "skipLibCheck": true, + "composite": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "types": ["node"], }, - "include": [ - "src" - ], - "exclude": [ - "node_modules", - "dist" - ], -} -\ No newline at end of file + "include": ["src", "src/data/*.json"], + "exclude": ["node_modules", "dist"] + } + +\ No newline at end of file diff --git a/locales/tsup.config.ts b/locales/tsup.config.ts @@ -1,11 +0,0 @@ -import { defineConfig } from "tsup"; - -export default defineConfig({ - entry: ['src/index.ts'], - format: ['esm', 'cjs'], - dts: true, - outDir: 'dist', - splitting: false, - clean: true, - sourcemap: true, -});