;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Mathieu Othacehe ;;; Copyright © 2019 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu installer locale) #:use-module (gnu installer utils) #:use-module ((gnu build locale) #:select (normalize-codeset)) #:use-module (guix records) #:use-module (json) #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:use-module (ice-9 regex) #:expo
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/guix-download.sh')
0 files changed, 0 insertions, 0 deletions
ocales alpha2 alpha3) `((alpha2 . ,alpha2) (alpha3 . ,alpha3) (name . ,name))))) (append (vector->list (assoc-ref (json->scm port-iso639-3) "639-3")) (vector->list (assoc-ref (json->scm port-iso639-5) "639-5"))))))))) (define (language-code->language-name languages language-code) "Using LANGUAGES as a list of ISO639 association lists, return the language name corresponding to the given LANGUAGE-CODE." (let ((iso639-language (find (lambda (language) (or (and=> (iso639-language-alpha2 language) (lambda (alpha2) (string=? alpha2 language-code))) (string=? (iso639-language-alpha3 language) language-code))) languages))) (iso639-language-name iso639-language))) ;;; ;;; Territory. ;;; (define (iso3166-territory-alpha2 assoc) (assoc-ref assoc 'alpha2)) (define (iso3166-territory-alpha3 assoc) (assoc-ref assoc 'alpha3)) (define (iso3166-territory-name assoc) (assoc-ref assoc 'name)) (define (iso3166->iso3166-territories iso3166) "Return a list of ISO3166 association lists created from the parsing of ISO3166 file." (call-with-input-file iso3166 (lambda (port) (map (lambda (hash) `((alpha2 . ,(assoc-ref hash "alpha_2")) (alpha3 . ,(assoc-ref hash "alpha_3")) (name . ,(assoc-ref hash "name")))) (vector->list (assoc-ref (json->scm port) "3166-1")))))) (define (territory-code->territory-name territories territory-code) "Using TERRITORIES as a list of ISO3166 association lists return the territory name corresponding to the given TERRITORY-CODE." (let ((iso3166-territory (find (lambda (territory) (or (and=> (iso3166-territory-alpha2 territory) (lambda (alpha2) (string=? alpha2 territory-code))) (string=? (iso3166-territory-alpha3 territory) territory-code))) territories))) (iso3166-territory-name iso3166-territory))) ;;; ;;; Configuration formatter. ;;; (define (locale->configuration locale) "Return the configuration field for LOCALE." `((locale ,locale)))