kartotherian/babel

Name: babel

Owner: kartotherian

Description: Kartotherian library to support multi-lingual maps

Created: 2017-02-10 01:55:59.0

Updated: 2018-05-15 16:56:09.0

Pushed: 2018-05-15 16:56:08.0

Homepage: null

Size: 154

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status Coverage Status

@kartotherian/babel

Tile source to restructure vector PBFs for multilingual usecases, such as convert a single JSON object into multiple key/values, or to replace all language key/value names with a single one.

Usage examples

Tile is generated with 'name' field set a JSON-encoded key-value object. Babel can be used to convert that tile to a tile, with each value in the object becoming a tag of its own, e.g. 'name_en', 'name_fr', … . Also, babel can be used to replace multiple 'name_lang' tags with a single 'name' tag right before rendering it, choosing the best language based on the fallback rules, but only if it is different from the 'name' tag.

ocess tiles from 'gen' source, expanding json string into multiple tags
2tags:
i: json2tags://
rams:
source: {ref: gen}
tag: name   # optional, 'name' is the default
aml
ocess tiles from 'store' source, replacing all 'name_*' tags with a single 'name' tag
l:
i: babel://
rams:
source: {ref: store}

# optional, 'name' is the default
tag: name

# optional, used by default if no 'lang' code is passed to getAsync()
defaultLanguage: 'en' 

# optional map of fallback values. Can be a json file or an object value
languageMap: '/my/path/fallback.json'

# -- OR --

languageMap:
  en: ['fr', 'es', 'de']
  ru: ['be']
Language resolution

For babel://, the language of the name_ is chosen based on these rules:

getAsync({z,x,y, lang:'xx'):

Scripts

Babel gets the CLDR defined script name (Latn, Cyrl, … ) based on the language code. It also uses a few overrides from the overrides.json. This file should be updated with any language IDs found in OSM data.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.