Difference between revisions of "Module:Template translation"

Jump to navigation Jump to search
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.language.isKnownLanguageTag( subpage ) )
     if (type (mw.ustring.match( subpage, "'" )) == nil )
     then
     then
         local translation = mw.title.new( namespace..template..'/'..subpage )
         if ( mw.language.isKnownLanguageTag( subpage ) )
        if ( translation.id ~= 0)
         then
         then
             langcode='/'..subpage
             local translation = mw.title.new( namespace..template..'/'..subpage )
            if ( translation.id ~= 0)
            then
                langcode='/'..subpage
            end
         end
         end
     end
     end
Anonymous user

Navigation menu