Worldref

io.github.arj-89由 GitHub 帳號 arj-89 發布v1.1.2更新於 Nov 7, 2026

Every country in Arabic and English: names, nationalities, dial codes, phone validation.

已驗證STDIO僅桌面位置與生活資料與分析

概覽

AI 產生的概覽

本機 MCP 伺服器,為助理提供阿拉伯文與英文的國家參考資料:國家詳情、搜尋、電話號碼驗證和 ISO 行政區劃。

可以做什麼
  • 查詢單一國家或地區:名稱、國籍、區碼、貨幣、首都、人口、時區、語言、週起始日與曆法、地址格式、緊急電話、插座類型與體育代碼
  • 依阿拉伯文或英文名稱與別名、ISO 代碼或區碼搜尋國家
  • 驗證並解析使用者輸入的阿拉伯數字或西文數字電話號碼,輸出國際 E.164 格式、所屬國家及是否為手機號碼
  • 列出某國的 ISO 3166-2 行政區劃,含阿拉伯文與英文名稱
適用情境
適合助理需要可靠的雙語國家資訊時使用,例如製作國家選擇器、驗證電話號碼,或回答關於首都、貨幣、區碼、地址格式與地區的問題。它是唯讀的參考資料集,並非即時服務。
執行需求
以本機 stdio 程序執行,例如透過 npx -y worldref mcp 啟動,因此需要 Node.js。未宣告任何帳號、API 金鑰、環境變數或請求標頭,工具本身也不需要網路存取。
安裝前請注意
資料集遵循明確的編輯政策:部分地點被排除或以特定方式歸屬,且不接受修改該政策的請求,因此結果可能與其他參考資料不一致。缺失值以 null 回傳,應視為未知,不要自行補齊。共用的國際區碼無法僅憑號碼判斷所屬國家。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Worldref,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

worldref

Every country in Arabic, English, or both: names, nationalities, capitals, currencies, languages, time zones, dial codes, phone validation, address formats and subdivisions. One dataset, ready for JSON, CSV, SQL, TypeScript, Python, Swift, Kotlin, Dart, PHP, Go and C#, and for AI agents (MCP).

العربية · Website and search demo · Best practices · Field reference · Data sources

[CI] [npm] [PyPI] [pub.dev] [NuGet] [Packagist] [MCP Registry] [countries] [subdivisions] [languages]

js
import { countries, search, parsePhone, byIso2 } from "worldref";
byIso2("SA").name_ar;                       // "السعودية"byIso2("SA").nationality.nationality_ar_f;  // "سعودية"search(countries, "الامارات", "ar")[0].iso2; // "AE"  (ignores «ال», hamza and tashkeel)parsePhone("٠٥٠١٢٣٤٥٦٧", byIso2("SA"));     // { e164: "+966501234567", valid: true, mobile: true, ... }

Why worldref

  • Arabic done natively. Short common names (السعودية, not a transliteration), nationality in masculine and feminine (سعودي / سعودية), search that ignores «ال», tashkeel, tatweel and hamza forms, Arabic-Indic and Persian digits accepted everywhere, and sort keys that give correct Arabic alphabetical order on every platform.
  • Works for one language or two. Every file comes in three builds: bilingual (name_ar, name_en), Arabic-only (name) and English-only (name).
  • Phone fields that work. Dial codes, valid lengths, mobile prefixes and exact validation patterns for every country, shared calling codes resolved (+1, +7, +44...), and international (E.164) output.
  • Everything a form or app needs in one place: official names, capitals, currencies with symbols (including the new Saudi riyal sign), official languages, week start and weekend, preferred calendars (including Umm al-Qura), postal code rules, address templates, emergency numbers, plug types and voltage, FIFA and IOC codes, and ISO 3166-2 subdivisions.
  • Sourced, not guessed. Official sources first (Unicode CLDR, Google libphonenumber, World Bank, IANA, ITU and government sources). Every column names its source in data/sources.json. A missing value is null, never a guess or a machine translation.

Install

Published on npm, PyPI, pub.dev, Packagist, NuGet and the MCP Registry. Swift, Kotlin and Go install straight from this repository.

StackInstall
JavaScript, TypeScript (web, Node 20.10+, React Native, Bun, Deno)npm i worldref
CDN (no build step)https://cdn.jsdelivr.net/npm/[email protected]/data/worldref.json
Swift (iOS, macOS)Swift Package Manager: https://github.com/arj-89/worldref, from 1.1.2, product WorldRef
Kotlin, AndroidJitPack: maven("https://jitpack.io"), then implementation("com.github.arj-89:worldref:v1.1.2")
Pythonpip install worldref
Dart, Flutterdart pub add worldref (Flutter: flutter pub add worldref)
PHP, Laravelcomposer require arj-89/worldref
Gogo get github.com/arj-89/worldref/[email protected]
C#, .NETdotnet add package WorldRef
Any languageJSON, CSV and SQL (Postgres, MySQL, SQLite) in data/ and on the releases page
AI agentsMCP server: npx -y worldref mcp (listed in the MCP Registry as io.github.arj-89/worldref)
No installOne country: https://arj-89.github.io/worldref/api/v1/sa.json

Each language folder has its own README with a usage example: python, Swift, kotlin, dart, php, go, csharp.

Use only what you need

  • The data is split into modules that share the key iso2: core, nationality, phone, currency, geo, locale, address, travel, sports, plus subdivisions. Find them in data/modules/.
  • Each module comes in 3 builds: .json (Arabic and English), .ar.json (Arabic only), .en.json (English only).
  • JS/TS: import only the module you use, and your bundler ships only that file:
    js
    import phone from "worldref/data/modules/phone.json" with { type: "json" };import { parsePhone } from "worldref/helpers";
  • Other languages: load only the module files you need. data/worldref.json has everything.
  • One country, no install: https://arj-89.github.io/worldref/api/v1/{iso2}.json.
  • A missing value is null (or an empty list). Treat it as unknown; never fill it in.
  • Within a major version, fields are never renamed or removed.

Recipes

Country picker (user's country first, then alphabetical in the UI language):

js
import { countries, sortCountries, search } from "worldref";const list = sortCountries(countries, "ar", "SA");          // السعودية first, then Arabic orderconst hits = search(countries, userQuery, "ar");            // names, aliases, ISO codes, +966 / 00966 / 966

Show: flag, name in the UI language, then the dial code. In Arabic, isolate the dial code left-to-right (<bdi dir="ltr">+966</bdi>).

Phone field (store the international form plus the country the user picked):

js
const p = parsePhone(input, byIso2(pickedIso2), countries);if (p?.valid && p.mobile) save({ phone: p.e164, phone_country: p.iso2 });

Nationality field (only rows that have one: countries, plus Taiwan, Hong Kong and Macau):

js
const options = countries.filter((c) => c.nationality.nationality_en);const label = (c, female) => (female ? c.nationality.nationality_ar_f : c.nationality.nationality_ar_m);

Database seed: run data/sql/postgres.sql (or mysql.sql, sqlite.sql). It creates countries and subdivisions.

Best practices

Every rule below is built into the helpers of all eight packages and locked by the shared tests in tests/vectors.json. Use the helpers; if you write your own, follow these rules exactly.

Search (normalize(), search())

  • Normalise both sides, the query and the names, the same way.
  • Arabic: drop «ال» at the start of every word (not only the first); remove tashkeel (fatha, damma, kasra, sukun, shadda, tanween) and tatweel (ـ); treat أ إ آ ٱ as ا, ة as ه, ى as ي, ؤ as و, ئ as ي. So «الإمارات», «امارات» and «الأمارات» all find the UAE.
  • Latin: ignore case and accents, and treat punctuation as a space, so «cote d'ivoire» finds Côte d’Ivoire.
  • Digits: convert Arabic-Indic (٠١٢٣٤٥٦٧٨٩) and Persian (۰۱۲۳۴۵۶۷۸۹) digits to Western before anything else.
  • Match names and aliases in both languages, ISO codes (SA, SAU), and dial codes with or without «+» or «00» (+966, 00966, 966).

Sorting (sortCountries())

  • Put the user's country first: from their profile, else the device region, else pin nothing.
  • Then sort by sort_ar or sort_en with plain string comparison. Do not use locale collation (Intl.Collator("ar"), localizedStandardCompare): neither ignores «ال», so every «ال» name bunches under ا.

Display

  • Show the flag, then the name in the UI language, then the dial code.
  • In Arabic, isolate the dial code and any Latin text left-to-right in the UI (<bdi dir="ltr">+966</bdi>, or U+2066 ... U+2069). The data never contains bidi marks.
  • Show Western numerals (0-9) in the UI, in both languages.
  • Use flag_svg on the web: Windows does not draw flag emoji.
  • Currency: show symbol (the Saudi riyal sign is U+20C1) and fall back to symbol_fallback (ر.س) where the font lacks the new sign.

Phone fields (parsePhone(), formatNational())

  • Accept whatever the user types: Arabic or Western digits, spaces, dashes, a leading 0, «+» or «00».
  • Store the international form (e164) together with the iso2 the user picked. Shared calling codes (+1, +7, +44, +599...) cannot be read back to one country from the number alone.
  • Validate a mobile with mobile_pattern. Where mobile_distinguishable is false (US, Canada), do not reject a number for not looking like a mobile.
  • Format for display with formatNational() (5X XXX XXXX style).

Nationality fields

  • List only rows where nationality.nationality_en is not null (countries, plus Taiwan, Hong Kong and Macau).
  • In Arabic, use the form that matches the person: nationality_ar_m (سعودي) or nationality_ar_f (سعودية).

Data

  • null (or an empty list) means unknown. Show it as unknown; never fill it from elsewhere.
  • Load only the modules you need; they join on iso2.
  • Pin a version (#v1.1.2, @1.1.2) so names and rules do not change under you.

Data policy

  • Israel is not in this dataset, in any file, under any name or code. A test enforces this on every output.
  • Palestine is «فلسطين» / "Palestine", a country, with its capital «القدس» / "Jerusalem". Numbers with +970 and +972 (including Jerusalem and the 1948 lines) are Palestinian numbers here. Its currencies are the Jordanian dinar and the shekel (shown as «شيكل» / "Shekel").
  • Disputed places follow the official positions of Saudi Arabia: Western Sahara is part of Morocco (no separate row), Kosovo is included, Northern Cyprus is not, and Taiwan, Hong Kong and Macau are territories that still have a nationality (they issue their own passports).
  • Requests to change this policy are closed without discussion. Corrections to data are welcome with a source link (see CONTRIBUTING).

Fields

Single-language builds drop the _ar / _en suffix (name_ar becomes name in .ar.json).

FieldModuleExample (SA)Meaning
iso2allSAISO 3166-1 alpha-2 code (XK for Kosovo). The key that joins every module.
iso3coreSAUISO 3166-1 alpha-3 code (XKK for Kosovo, as in CLDR).
iso_numericcore682ISO 3166-1 numeric code, as text to keep leading zeros.
kindcorecountrycountry (sovereign state, including Palestine, Vatican and Kosovo) or territory.
name_arcoreالسعوديةShort common name in Arabic.
name_encoreSaudi ArabiaShort common name in English.
official_name_arcoreالمملكة العربية السعوديةOfficial long name in Arabic, when a source states one.
official_name_encoreKingdom of Saudi ArabiaOfficial long name in English, when a source states one.
aliases_arcore["المملكة العربية السعودية","المملكة"...Other Arabic names people search with. For search only, not display.
aliases_encore["KSA","Kingdom of Saudi Arabia","Sau...Other English names people search with. For search only, not display.
flagcore🇸🇦Flag emoji (regional indicator pair). Windows does not draw these; use flag_svg on the web.
flag_svgcoreflags/sa.svgPath of the 4:3 SVG flag in this package.
continentcoreasiaafrica, americas, asia, europe or oceania (UN M49 via CLDR).
groupscore["gcc","arab_league"]Memberships: gcc, arab_league.
un_membercoretruetrue for the 193 UN member states.
tldcore.saCountry-code top-level domain, when one is delegated.
sort_arcoreسعوديهArabic sort key: compare these with plain string comparison for correct Arabic order (ignores «ال», hamza forms, tashkeel).
sort_encoresaudi arabiaEnglish sort key: compare with plain string comparison.
nationalitynationalityNationality names. Filled for countries and for TW, HK, MO; null for other territories.
nationality.nationality_ar_mnationalityسعوديArabic nationality, masculine (سعودي).
nationality.nationality_ar_fnationalityسعوديةArabic nationality, feminine (سعودية).
nationality.nationality_ennationalitySaudiEnglish nationality adjective (Saudi).
nationality.icao_codenationalitySAUICAO Doc 9303 code used on passports (mostly iso3; D for Germany, RKS for Kosovo).
phonephone[{"calling_code":"+966","leading_digi...Numbering plans for this row. Most rows have one; some have several (Palestine: +970 and +972).
phone[].calling_codephone+966International calling code with +.
phone[].leading_digitsphonenullRegex the national number must start with when the calling code is shared (e.g. +1 809|829|849 for DO). null when the code is not shared this way.
phone[].primaryphonetruetrue when this row is the default country for the calling code.
phone[].trunk_prefixphone0Digit(s) dropped from local numbers before the calling code (0 in 0501234567).
phone[].patternphone(?:[15]\d|800|92)\d{7}Regex for any valid national number (all types). Match against the full national number.
phone[].lengthsphone[9,10]Valid national number lengths, all types.
phone[].mobile_patternphone579[0-8]\d{5}|5(?:[013-689]\d|7[0-8])...Regex for a valid mobile national number. Match against the full national number.
phone[].mobile_lengthsphone[9]Valid mobile national number lengths.
phone[].mobile_prefixesphone["50","51","53","54","55","56","57","...Leading digits of mobile numbers (up to 3 digits). Quick check; use mobile_pattern for exact validation.
phone[].mobile_distinguishablephonetruefalse when mobile and landline numbers look the same (US, CA).
phone[].mobile_examplephone512345678Example mobile national number, good as an input placeholder.
phone[].mobile_formatphone## ### ####Display grouping for a mobile national number, # = digit.
currenciescurrency[{"code":"SAR","name_ar":"ريال سعودي"...Currencies in use.
currencies[].codecurrencySARISO 4217 code.
currencies[].name_arcurrencyريال سعوديCurrency name in Arabic.
currencies[].name_encurrencySaudi RiyalCurrency name in English.
currencies[].symbolcurrency⃁Symbol (the new Unicode sign where one exists, e.g. the riyal sign).
currencies[].symbol_arcurrencyر.س.Symbol as written in Arabic (ر.س).
currencies[].symbol_fallbackcurrencyر.سText to show when the font lacks the new sign.
geogeoGeography.
geo.capital_argeoالرياضCapital in Arabic.
geo.capital_engeoRiyadhCapital in English.
geo.latgeo23.7167Latitude of the country's centre point.
geo.lnggeo44.1167Longitude of the country's centre point.
geo.area_km2geo2149690Area in square kilometres.
geo.populationgeo36973555Population.
geo.population_yeargeo2025Year of the population figure.
geo.timezonesgeo["Asia/Riyadh"]IANA time zone names.
geo.driving_sidegeorightleft or right.
localelocaleLocale conventions.
locale.languageslocale[{"code":"ar","name_ar":"العربية","na...Official languages, most spoken first.
locale.languages[].codelocalearBCP 47 language code.
locale.languages[].name_arlocaleالعربيةLanguage name in Arabic.
locale.languages[].name_enlocaleArabicLanguage name in English.
locale.week_startlocalesunFirst day of the week (sun, mon, sat...).
locale.weekendlocale["fri","sat"]Weekend days.
locale.calendarslocale["gregorian","islamic-umalqura","isla...Calendars in use, most preferred first (gregorian, islamic-umalqura...).
locale.measurementlocalemetricmetric, us or uk.
addressaddressPostal address conventions.
address.postal_code_formataddress#####Postal code shape: # = digit, @ = letter.
address.postal_code_regexaddress^(?:\d{5})$Regex for a valid postal code.
address.postal_code_exampleaddress11564Example postal code.
address.address_formataddress%N%n%O%n%A%n%C %ZAddress template: %N name, %O organisation, %A street, %D district, %C city, %S region, %Z postal code, %X sorting code, %n new line.
address.region_label_araddressnullWhat the top-level region is called, in Arabic.
address.region_label_enaddressnullWhat the top-level region is called (state, province, emirate...).
traveltravelTravel facts.
travel.emergencytravelEmergency numbers confirmed from an official source. A null service means: call general.
travel.emergency.policetravel999Police.
travel.emergency.ambulancetravel997Ambulance.
travel.emergency.firetravel998Fire and civil defence.
travel.emergency.generaltravel911All-services number (112, 911, 999...).
travel.plug_typestravel["G"]IEC plug letters (A to N).
travel.voltagetravel[220,230]Residential mains voltages.
travel.frequency_hztravel[60]Mains frequency in hertz.
sportssportsSports codes.
sports.fifasportsKSAFIFA country code.
sports.iocsportsKSAIOC country code.
subdivisions.iso2subdivisionsSACountry code.
subdivisions.codesubdivisionsSA-01ISO 3166-2 code (SA-01).
subdivisions.name_arsubdivisionsمنطقة الرياضName in Arabic.
subdivisions.name_ensubdivisionsRiyadhName in English.
subdivisions.parentsubdivisionsnullISO 3166-2 code of the parent subdivision, for nested ones.

FAQ

How do I get a list of countries in Arabic? Use data/worldref.ar.json (or data/modules/core.ar.json for names only). Each row has name in Arabic. For a ready-made picker order, sort by sort (it ignores «ال» and hamza forms).

Where is a list of nationalities in Arabic, masculine and feminine? data/modules/nationality.json: nationality_ar_m (سعودي) and nationality_ar_f (سعودية), plus nationality_en (Saudi).

How do I validate a Saudi mobile number? parsePhone(input, byIso2("SA")) and check valid && mobile. The rule is in phone[0].mobile_pattern: 9 digits starting with 50, 51, 53 to 59 after dropping the leading 0. Arabic digits are accepted.

Why is travel.emergency.police null for some countries? Only numbers confirmed by an official source are published. If a service is null, call general.

Can I use this commercially? Yes. Code is MIT; data licences (Unicode, Apache-2.0, CC-BY-4.0, CC0, public domain) all allow commercial use with attribution where required. See LICENSE.

How current is it? An automated job checks the upstream sources monthly (population quarterly) and releases a patch when they change and every test passes. Versions are in data/meta.json.

For AI agents

Start at llms.txt and AGENTS.md. Schemas are in schema/. The MCP server (npx -y worldref mcp) offers get_country, search_countries, validate_phone and list_subdivisions. Answer from the data only and treat null as unknown.

Roadmap

Planned for 1.2.0 (new, non-breaking):

  1. Official Arabic names: 222 rows are empty today, the largest gap in the data.
  2. Subdivision types in both languages (region, province, emirate, state).
  3. More forgiving search: names typed without punctuation or with small typos ("cote divoire", "Kuwiat").
  4. An address-form helper: the fields, order and labels of a country's address form in Arabic or English.
  5. Kotlin on Maven Central, alongside JitPack.
  6. Cities: a new cities module with Arabic and English names, linked to each country and subdivision.

Sources and licences

Code: MIT. Data: Unicode CLDR 49 (Unicode-3.0), Google libphonenumber v9.0.42 and address metadata (Apache-2.0, modified), World Bank (CC-BY-4.0), Wikidata (CC0), CIA World Factbook final edition and IANA (public domain), flag-icons (MIT), and official government sources for emergency numbers. Full texts: LICENSES/. Per-column sources and every editorial decision: data/sources.json.

Cite as: see CITATION.cff.

來源:README.md,提交 34315f6

工具

4

get_country

Everything worldref knows about one country or territory: names, official names, nationality, dial codes and phone rules, currencies, capital, population, time zones, languages, week and calendar, address format, emergency numbers, plugs, sports codes. Missing values are null: report them as unknown, never guess.

輸入參數iso2必填lang

search_countries

Find countries by name or alias in Arabic or English (ignores «ال», tashkeel and hamza forms), by ISO code, or by dial code (+966, 00966, 966). Returns iso2, names and flag, best match first.

輸入參數langlimitquery必填

validate_phone

Parse a phone number as a user typed it (Arabic or Western digits, local or international form). Returns the international (E.164) form, the country it belongs to, and whether it is a valid number and a mobile number.

輸入參數number必填country必填

list_subdivisions

ISO 3166-2 subdivisions (regions, provinces, states, emirates) of a country, with Arabic and English names.

輸入參數iso2必填

版本歷史

1
  1. v1.1.2最新Nov 4, 2026

評分

已滿足適用檢查項的 80%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。