@etsoo/appscript
Version:
Applications shared TypeScript framework
104 lines (103 loc) • 3.04 kB
JavaScript
import { AddressContinent } from "./AddressContinent";
/**
* Address or region
*/
export class AddressRegion {
/**
* Get country or region by id
* @param id Country id
*/
static getById(id) {
return AddressRegion.all.find((c) => c.id === id);
}
// Typescript constructor shorthand
constructor(id, id3, nid, continent, exitCode, idd, nationalPrefix, currency, languages, label = id) {
this.id = id;
this.id3 = id3;
this.nid = nid;
this.continent = continent;
this.exitCode = exitCode;
this.idd = idd;
this.nationalPrefix = nationalPrefix;
this.currency = currency;
this.languages = languages;
this.label = label;
this.continentId = AddressContinent[continent];
}
}
/**
* CN - China
*/
AddressRegion.CN = new AddressRegion("CN", "CHN", "156", AddressContinent.AS, "00", "+86", "0", "CNY", ["zh-Hans-CN", "zh-CN"]);
/**
* HK - HK, China
* 中国香港
*/
AddressRegion.HK = new AddressRegion("HK", "HKG", "344", AddressContinent.AS, "001", "+852", undefined, "HKD", ["zh-Hant-HK", "zh-HK", "en-HK"]);
/**
* SG - Singapore
* 新加坡
*/
AddressRegion.SG = new AddressRegion("SG", "SGP", "702", AddressContinent.AS, "000", "+65", undefined, "SGD", ["zh-Hans-SG", "zh-SG", "en-SG"]);
/**
* JP - Japan
* 日本
*/
AddressRegion.JP = new AddressRegion("JP", "JPN", "392", AddressContinent.AS, "010", "+81", "0", "JPY", ["ja-JP"]);
/**
* US - United States
* 美国
*/
AddressRegion.US = new AddressRegion("US", "USA", "840", AddressContinent.NA, "011", "+1", "1", "USD", ["en-US"]);
/**
* CA - Canada
* 加拿大
*/
AddressRegion.CA = new AddressRegion("CA", "CAN", "124", AddressContinent.NA, "011", "+1", "1", "CAD", ["en-CA", "fr-CA"]);
/**
* AU - Australia
* 澳大利亚
*/
AddressRegion.AU = new AddressRegion("AU", "AUS", "036", AddressContinent.OC, "0011", "+61", "0", "AUD", ["en-AU"]);
/**
* NZ - New Zealand
* 新西兰
*/
AddressRegion.NZ = new AddressRegion("NZ", "NZL", "554", AddressContinent.OC, "00", "+64", "0", "NZD", ["en-NZ", "mi-NZ"]);
/**
* GB - Great Britain
* 英国
*/
AddressRegion.GB = new AddressRegion("GB", "GBR", "826", AddressContinent.EU, "00", "+44", "0", "GBP", ["en-GB"]);
/**
* IE - Ireland
* 爱尔兰
*/
AddressRegion.IE = new AddressRegion("IE", "IRL", "372", AddressContinent.EU, "00", "+353", "0", "EUR", ["en-IE"]);
/**
* DE - Germany
* 德国
*/
AddressRegion.DE = new AddressRegion("DE", "DEU", "276", AddressContinent.EU, "00", "+49", "0", "EUR", ["de-DE"]);
/**
* FR - France
* 法国
*/
AddressRegion.FR = new AddressRegion("FR", "FRA", "250", AddressContinent.EU, "00", "+33", "0", "EUR", ["fr-FR"]);
/**
* All countries and regions
*/
AddressRegion.all = [
AddressRegion.CN,
AddressRegion.HK,
AddressRegion.SG,
AddressRegion.JP,
AddressRegion.US,
AddressRegion.CA,
AddressRegion.AU,
AddressRegion.NZ,
AddressRegion.GB,
AddressRegion.IE,
AddressRegion.DE,
AddressRegion.FR
];