[Test] 5.1.0 Internacionalización

by Francisco

HTML

<link rel="stylesheet" href="http://publicacion.i-administracion.junta-andalucia.es/mapea/assets/css/mapea-5.1.0.ol.min.css">
<script src="http://publicacion.i-administracion.junta-andalucia.es/mapea/js/mapea-5.1.0.ol.min.js"></script>
<script src="http://publicacion.i-administracion.junta-andalucia.es/mapea/js/configuration-5.1.0.js"></script>
<div id="map"></div>

CSS

html,
 body {
   margin: 0;
   padding: 0;
   height: 100%;
   overflow: hidden;
 }

JavaScript

M.language.setLang("en");

const mapa = M.map({
  container: 'map',
  controls: ['layerswitcher','scale','scaleline','rotate'],
  wmcfile: ['mapa', 'satelite']
});

const campamentos = new M.layer.GeoJSON({
  name: "Campamentos",
  url: "http://geostematicos-sigc.juntadeandalucia.es/geoserver/sepim/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=sepim:campamentos&outputFormat=application/json&",
  extract: true
});

campamentos.setStyle(new M.style.Cluster());

mapa.addControls(new M.control.GetFeatureInfo(
 'gml', 
 {buffer: 1000}));

mapa.addLayers(campamentos);

// Añadir mis textos en ingles
let textosIngles = M.language.getTranslation('en');
textosIngles.miPlugin = {'p1':'value 1', 'p2': 'value 2'};
// Desde el plugin
console.log(M.language.getValue('miPlugin').p1);

// La siguiente instruccion aplica en caliente el español
// M.language.setLang("es");

// M.language.addTranslation('B',{});
// let textosBorja = M.language.getTranslation('B');
// textosBorja.miPlugin = {'p1':'value Borja1', 'p2': 'value Borja2'};
// M.language.getValue('miPlugin','B').p1