{"action":"created","issue":{"url":"https://api.github.com/repos/vincentarelbundock/countrycode/issues/148","repository_url":"https://api.github.com/repos/vincentarelbundock/countrycode","labels_url":"https://api.github.com/repos/vincentarelbundock/countrycode/issues/148/labels{/name}","comments_url":"https://api.github.com/repos/vincentarelbundock/countrycode/issues/148/comments","events_url":"https://api.github.com/repos/vincentarelbundock/countrycode/issues/148/events","html_url":"https://github.com/vincentarelbundock/countrycode/issues/148","id":232262316,"number":148,"title":"add CLDR country names to data/extra","user":{"login":"cjyetman","id":1708872,"avatar_url":"https://avatars3.githubusercontent.com/u/1708872?v=3","gravatar_id":"","url":"https://api.github.com/users/cjyetman","html_url":"https://github.com/cjyetman","followers_url":"https://api.github.com/users/cjyetman/followers","following_url":"https://api.github.com/users/cjyetman/following{/other_user}","gists_url":"https://api.github.com/users/cjyetman/gists{/gist_id}","starred_url":"https://api.github.com/users/cjyetman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjyetman/subscriptions","organizations_url":"https://api.github.com/users/cjyetman/orgs","repos_url":"https://api.github.com/users/cjyetman/repos","events_url":"https://api.github.com/users/cjyetman/events{/privacy}","received_events_url":"https://api.github.com/users/cjyetman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-05-30T13:58:34Z","updated_at":"2017-06-01T21:28:05Z","closed_at":"2017-06-01T21:28:05Z","body":"I briefly spoke to @alistaire47 about his [`passport`](https://github.com/alistaire47/passport) package, which has a lot of overlap with `countrycode`. One of this motivations was to get \"better\" standardized country names. The primary set of country names used in `passport` is the set from the CLDR (Common Locale Data Repository Project) project of the Unicode Consortium. They have country names in many different languages and language/country variations. The stated [goal](http://cldr.unicode.org/translation/country-names#TOC-Customary-Names) is \"the most customary name used in your language, even if it is not the official name\".\r\n\r\nI suspect @vincentarelbundock won't want to change the default country names in `countrycode`, nor add 500+ language variations to the default dictionary in `countrycode`, but I think CLDR's \"most customary\" names plus the many language variants might be useful to enough people to warrant putting them in the [`data/extras`](https://github.com/vincentarelbundock/countrycode/tree/master/data/extra) directory, and possibly modifying the documentation to be a bit more explicit about how to use it.\r\n\r\nhere's some code to build a custom dictionary using the full CLDR set in JSON from [their Github page](https://github.com/unicode-cldr/cldr-localenames-full)...\r\n```r\r\nlibrary(jsonlite)\r\nlibrary(curl)\r\nlibrary(dplyr)\r\nlibrary(countrycode)\r\nlibrary(readr)\r\n\r\nfull_url <- 'https://api.github.com/repos/unicode-cldr/cldr-localenames-full/releases/latest'\r\nfull_zip_url <- jsonlite::fromJSON(full_url)$zipball_url\r\nzipfile <- curl::curl_download(full_zip_url, tempfile())\r\n\r\nfilelist <- unzip(zipfile, list = T)\r\nfilelist <- filelist$Name[grep('/territories.json$', filelist$Name)]\r\nfilelist <- unzip(zipfile, files = filelist, overwrite = T, exdir = tempdir())\r\n\r\ncldr_countrynames <- countrycode::countrycode_data\r\n\r\nfor (file in filelist) {\r\n  lang <- jsonlite::fromJSON(file)\r\n  lang <- lang[[1]][[1]]$localeDisplayNames$territories\r\n  lang <- data.frame(names(lang), unlist(lang), stringsAsFactors = F)\r\n  names(lang) <- c('iso2c', paste0('cldr.full.', rev(strsplit(file, '/')[[1]])[2]))\r\n  cldr_countrynames <- dplyr::left_join(cldr_countrynames, lang)\r\n}\r\n\r\nunlink(filelist)\r\nunlink(zipfile)\r\n\r\nreadr::write_csv(cldr_countrynames, 'cldr_full.csv', na = '')\r\n```\r\n\r\nand if the custom dictionary were committed to the `countrycode` repo, then something like this would be possible...\r\n```r\r\ncldr_full <- readr::read_csv('https://raw.githubusercontent.com/vincentarelbundock/countrycode/master/data/extra/cldr_full.csv')\r\ncountries <- c('USA', 'Macedonia', 'Congo', 'South Korea')\r\ncountrycode::countrycode(countries, 'country.name', 'country.name')\r\ncountrycode::countrycode(countries, 'country.name.en.regex', 'cldr.full.en-US-POSIX', custom_dict = cldr_full, origin_regex = TRUE)\r\ncountrycode::countrycode(countries, 'country.name.en.regex', 'cldr.full.ta-MY', custom_dict = cldr_full, origin_regex = TRUE)\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/vincentarelbundock/countrycode/issues/comments/305625927","html_url":"https://github.com/vincentarelbundock/countrycode/issues/148#issuecomment-305625927","issue_url":"https://api.github.com/repos/vincentarelbundock/countrycode/issues/148","id":305625927,"user":{"login":"cjyetman","id":1708872,"avatar_url":"https://avatars3.githubusercontent.com/u/1708872?v=3","gravatar_id":"","url":"https://api.github.com/users/cjyetman","html_url":"https://github.com/cjyetman","followers_url":"https://api.github.com/users/cjyetman/followers","following_url":"https://api.github.com/users/cjyetman/following{/other_user}","gists_url":"https://api.github.com/users/cjyetman/gists{/gist_id}","starred_url":"https://api.github.com/users/cjyetman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjyetman/subscriptions","organizations_url":"https://api.github.com/users/cjyetman/orgs","repos_url":"https://api.github.com/users/cjyetman/repos","events_url":"https://api.github.com/users/cjyetman/events{/privacy}","received_events_url":"https://api.github.com/users/cjyetman/received_events","type":"User","site_admin":false},"created_at":"2017-06-01T21:28:05Z","updated_at":"2017-06-01T21:28:05Z","body":"moved this over here: vincentarelbundock/countryyear#21"}}
{"actor":{"display_login":"cjyetman"}}