en:Module:Wd 2017年5月12日 (金) 08:40(UTC)より
template>K-iczn (en:Module:Wd 2017年5月10日 (水) 19:38(UTC)より) |
template>K-iczn (en:Module:Wd 2017年5月12日 (金) 08:40(UTC)より) |
||
360行目: | 360行目: | ||
function addDelimiters(num) | function addDelimiters(num) | ||
return i18n.addDelimiters(num) | return i18n.addDelimiters(num) | ||
end | |||
function replaceDecimalMark(num) | |||
return mw.ustring.gsub(num, "[.]", i18n['numeric']['decimal-mark'], 1) | |||
end | end | ||
605行目: | 609行目: | ||
-- strip + signs from front | -- strip + signs from front | ||
local value = mw.ustring.gsub(snak.datavalue.value['amount'], "^\+(.+)$", "%1") | local value = mw.ustring.gsub(snak.datavalue.value['amount'], "^\+(.+)$", "%1") | ||
if not raw then | if not raw then | ||
-- replace decimal mark based on locale | |||
value = replaceDecimalMark(value) | |||
-- add delimiters for readability | |||
value = addDelimiters(value) | value = addDelimiters(value) | ||
local unit = convertUnit(snak.datavalue.value['unit'], link) | local unit = convertUnit(snak.datavalue.value['unit'], link) | ||
if unit then | if unit then | ||
value = value .. unit | value = value .. unit | ||
831行目: | 838行目: | ||
local precision, numDigits, strFormat, value, globe | local precision, numDigits, strFormat, value, globe | ||
local latValue, latitude, latDegrees, latMinutes, latSeconds | local latValue, latitude, latDegrees, latMinutes, latSeconds | ||
local lonValue, longitude, lonDegrees, lonMinutes, lonSeconds | local lonValue, longitude, lonDegrees, lonMinutes, lonSeconds | ||
local lonDirection | local latDirection, latDirectionN, latDirectionS, latDirectionEN | ||
local lonDirection, lonDirectionE, lonDirectionW, lonDirectionEN | |||
local | local latDirectionEN_N = "N" | ||
local | local latDirectionEN_S = "S" | ||
local | local lonDirectionEN_E = "E" | ||
local | local lonDirectionEN_W = "W" | ||
if raw then | if not raw then | ||
latDirectionN = i18n['coord']['latitude-north'] | |||
latDirectionS = i18n['coord']['latitude-south'] | |||
lonDirectionE = i18n['coord']['longitude-east'] | |||
lonDirectionW = i18n['coord']['longitude-west'] | |||
degSymbol = i18n['coord']['degrees'] | |||
minSymbol = i18n['coord']['minutes'] | |||
secSymbol = i18n['coord']['seconds'] | |||
separator = i18n['coord']['separator'] | |||
else | |||
latDirectionN = latDirectionEN_N | |||
latDirectionS = latDirectionEN_S | |||
lonDirectionE = lonDirectionEN_E | |||
lonDirectionW = lonDirectionEN_W | |||
degSymbol = "/" | degSymbol = "/" | ||
minSymbol = "/" | minSymbol = "/" | ||
851行目: | 873行目: | ||
if latitude < 0 then | if latitude < 0 then | ||
latDirection = | latDirection = latDirectionS | ||
latDirectionEN = latDirectionEN_S | |||
latitude = math.abs(latitude) | latitude = math.abs(latitude) | ||
else | |||
latDirection = latDirectionN | |||
latDirectionEN = latDirectionEN_N | |||
end | end | ||
if longitude < 0 then | if longitude < 0 then | ||
lonDirection = | lonDirection = lonDirectionW | ||
lonDirectionEN = lonDirectionEN_W | |||
longitude = math.abs(longitude) | longitude = math.abs(longitude) | ||
else | |||
lonDirection = lonDirectionE | |||
lonDirectionEN = lonDirectionEN_E | |||
end | end | ||
900行目: | 931行目: | ||
lonSeconds = string.format(strFormat, lonSeconds) | lonSeconds = string.format(strFormat, lonSeconds) | ||
-- replace decimal marks based on locale | if not raw then | ||
-- replace decimal marks based on locale | |||
latSeconds = replaceDecimalMark(latSeconds) | |||
lonSeconds = replaceDecimalMark(lonSeconds) | |||
end | |||
latValue = latValue .. latSeconds .. secSymbol | latValue = latValue .. latSeconds .. secSymbol | ||
922行目: | 955行目: | ||
end | end | ||
value = "[https://tools.wmflabs.org/geohack/geohack.php?language="..self.langCode.."¶ms="..latitude.."_".. | value = "[https://tools.wmflabs.org/geohack/geohack.php?language="..self.langCode.."¶ms="..latitude.."_"..latDirectionEN.."_"..longitude.."_"..lonDirectionEN.."_globe:"..globe.." "..value.."]" | ||
end | end | ||
1,415行目: | 1,448行目: | ||
end | end | ||
-- if this module is being substituted then build a regular template call, otherwise expand the template | |||
if mw.isSubsting() then | if mw.isSubsting() then | ||
for i, v in pairs(params) do | for i, v in pairs(params) do |