diff --git a/README.md b/README.md
index af6cea6..5b3a5cf 100644
--- a/README.md
+++ b/README.md
@@ -110,6 +110,7 @@ Showcasing the languages supported by Mapbox Streets.
- [German](https://mapbox.github.io/mapbox-gl-language/examples/de.html)
- [Japanese](https://mapbox.github.io/mapbox-gl-language/examples/ja.html)
- [Korean](https://mapbox.github.io/mapbox-gl-language/examples/ko.html)
+- [Multilingual](https://mapbox.github.io/mapbox-gl-language/examples/multilingual.html)
- [Portuguese](https://mapbox.github.io/mapbox-gl-language/examples/pt.html)
- [Russian](https://mapbox.github.io/mapbox-gl-language/examples/ru.html)
- [Spanish](https://mapbox.github.io/mapbox-gl-language/examples/es.html)
diff --git a/examples/multilingual.html b/examples/multilingual.html
new file mode 100644
index 0000000..1fad1af
--- /dev/null
+++ b/examples/multilingual.html
@@ -0,0 +1,34 @@
+
+
+
+
+ Mapbox GL Language
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/index.js b/index.js
index e00802f..bda7206 100644
--- a/index.js
+++ b/index.js
@@ -23,7 +23,7 @@ function MapboxLanguage(options) {
this._defaultLanguage = options.defaultLanguage;
this._isLanguageField = options.languageField || /^\{name/;
this._getLanguageField = options.getLanguageField || function nameField(language) {
- return '{name_' + language + '}';
+ return language === 'mul' ? '{name}' : '{name_' + language + '}';
};
this._languageSource = options.languageSource || null;
this._languageTransform = options.languageTransform || function (style, language) {
@@ -34,7 +34,7 @@ function MapboxLanguage(options) {
}
};
this._excludedLayerIds = options.excludedLayerIds || [];
- this.supportedLanguages = options.supportedLanguages || ['ar', 'en', 'es', 'fr', 'de', 'ja', 'ko', 'pt', 'ru', 'zh'];
+ this.supportedLanguages = options.supportedLanguages || ['ar', 'en', 'es', 'fr', 'de', 'ja', 'ko', 'mul', 'pt', 'ru', 'zh'];
}
function standardSpacing(style) {
diff --git a/test/index.test.js b/test/index.test.js
index 9f288bc..133834e 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -41,7 +41,7 @@ test('setLanguage for different text fields', (assert) => {
[6, '{name_es}']
]
}
- }, 'switch style to spanish name field');
+ }, 'switch style to english name field');
var arStyle = language.setLanguage(style, 'ar');
assert.deepEqual(arStyle.layers[0].layout, {
@@ -53,7 +53,19 @@ test('setLanguage for different text fields', (assert) => {
[6, '{name_ar}']
]
}
- }, 'switch style to spanish arabic field');
+ }, 'switch style to arabic name field');
+
+ var mulStyle = language.setLanguage(style, 'mul');
+ assert.deepEqual(mulStyle.layers[0].layout, {
+ 'text-letter-spacing': 0.15,
+ 'text-field': {
+ 'base': 1,
+ 'stops': [
+ [0, '{abbr}'],
+ [6, '{name}']
+ ]
+ }
+ }, 'switch style to multilingual name field');
assert.end();
});