parent
e03bbeadfc
commit
339ef3555f
4 changed files with 15 additions and 6 deletions
|
@ -219,7 +219,7 @@ L.Util.sortFeatures = (features, sortKey) => {
|
||||||
score = valA
|
score = valA
|
||||||
.toString()
|
.toString()
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.localeCompare(valB.toString().toLowerCase(), L.locale || 'en', {
|
.localeCompare(valB.toString().toLowerCase(), L.lang || 'en', {
|
||||||
sensitivity: 'base',
|
sensitivity: 'base',
|
||||||
ignorePunctuation: true,
|
ignorePunctuation: true,
|
||||||
numeric: true,
|
numeric: true,
|
||||||
|
@ -537,7 +537,7 @@ L.U.Help = L.Class.extend({
|
||||||
|
|
||||||
formatURL: `${L._(
|
formatURL: `${L._(
|
||||||
'Supported variables that will be dynamically replaced'
|
'Supported variables that will be dynamically replaced'
|
||||||
)}: {bbox}, {lat}, {lng}, {zoom}, {east}, {north}..., {left}, {top}..., locale`,
|
)}: {bbox}, {lat}, {lng}, {zoom}, {east}, {north}..., {left}, {top}..., locale, lang`,
|
||||||
formatIconSymbol: L._(
|
formatIconSymbol: L._(
|
||||||
'Symbol can be either a unicode character or an URL. You can use feature properties as variables: ex.: with "http://myserver.org/images/{name}.png", the {name} variable will be replaced by the "name" value of each marker.'
|
'Symbol can be either a unicode character or an URL. You can use feature properties as variables: ex.: with "http://myserver.org/images/{name}.png", the {name} variable will be replaced by the "name" value of each marker.'
|
||||||
),
|
),
|
||||||
|
|
|
@ -500,6 +500,7 @@ L.U.FeatureMixin = {
|
||||||
properties.lng = center.lng
|
properties.lng = center.lng
|
||||||
properties.rank = this.getRank() + 1
|
properties.rank = this.getRank() + 1
|
||||||
if (L.locale) properties.locale = L.locale
|
if (L.locale) properties.locale = L.locale
|
||||||
|
if (L.lang) properties.lang = L.lang
|
||||||
if (typeof this.getMeasure !== 'undefined') {
|
if (typeof this.getMeasure !== 'undefined') {
|
||||||
properties.measure = this.getMeasure()
|
properties.measure = this.getMeasure()
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,9 +65,16 @@ L.U.Map.include({
|
||||||
],
|
],
|
||||||
|
|
||||||
initialize: function (el, geojson) {
|
initialize: function (el, geojson) {
|
||||||
if (geojson.properties && geojson.properties.locale)
|
// Locale name (pt_PT, en_US…)
|
||||||
|
// To be used for Django localization
|
||||||
|
if (geojson.properties.locale)
|
||||||
L.setLocale(geojson.properties.locale)
|
L.setLocale(geojson.properties.locale)
|
||||||
|
|
||||||
|
// Language code (pt-pt, en-us…)
|
||||||
|
// To be used in javascript APIs
|
||||||
|
if (geojson.properties.lang)
|
||||||
|
L.lang = geojson.properties.lang
|
||||||
|
|
||||||
// Don't let default autocreation of controls
|
// Don't let default autocreation of controls
|
||||||
const zoomControl =
|
const zoomControl =
|
||||||
typeof geojson.properties.zoomControl !== 'undefined'
|
typeof geojson.properties.zoomControl !== 'undefined'
|
||||||
|
|
|
@ -423,11 +423,12 @@ class MapDetailMixin:
|
||||||
properties["shortUrl"] = self.get_short_url()
|
properties["shortUrl"] = self.get_short_url()
|
||||||
|
|
||||||
if settings.USE_I18N:
|
if settings.USE_I18N:
|
||||||
locale = settings.LANGUAGE_CODE
|
lang = settings.LANGUAGE_CODE
|
||||||
# Check attr in case the middleware is not active
|
# Check attr in case the middleware is not active
|
||||||
if hasattr(self.request, "LANGUAGE_CODE"):
|
if hasattr(self.request, "LANGUAGE_CODE"):
|
||||||
locale = self.request.LANGUAGE_CODE
|
lang = self.request.LANGUAGE_CODE
|
||||||
locale = to_locale(locale)
|
properties["lang"] = lang
|
||||||
|
locale = to_locale(lang)
|
||||||
properties["locale"] = locale
|
properties["locale"] = locale
|
||||||
context["locale"] = locale
|
context["locale"] = locale
|
||||||
user = self.request.user
|
user = self.request.user
|
||||||
|
|
Loading…
Reference in a new issue