Difference between revisions of "Module:Template translation"
m
check for apostrophes before isKnownLanguageTag
>Guillom m (no more alpha) |
>Guillom m (check for apostrophes before isKnownLanguageTag) |
||
Line 28: | Line 28: | ||
--[[ If the subpage is a valid language code, check if a translation of the | --[[ If the subpage is a valid language code, check if a translation of the | ||
template exists in that language; if so, put it in langcode. | template exists in that language; if so, put it in langcode. | ||
Check first if there's an apostrophe, because they break the | |||
isKnownLanguageTag function. | |||
]] | ]] | ||
if ( mw. | if (type (mw.ustring.match( subpage, "'" )) == nil ) | ||
then | then | ||
if ( mw.language.isKnownLanguageTag( subpage ) ) | |||
then | then | ||
langcode='/'..subpage | local translation = mw.title.new( namespace..template..'/'..subpage ) | ||
if ( translation.id ~= 0) | |||
then | |||
langcode='/'..subpage | |||
end | |||
end | end | ||
end | end |