Module:Sandbox: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 27: Line 27:
         return nil
         return nil
     end
     end
end
-- Helper function to replace \"n with newlines
local function process_newlines(str)
    if str then
        return str:gsub('\\"n', '\n')
    end
    return str
end
end


Line 78: Line 70:
             return ''
             return ''
         end
         end
         return process_newlines(fallback) .. fallback_tooltip
         return fallback .. fallback_tooltip
     end
     end
      
      
Line 86: Line 78:
     end
     end
      
      
     return process_newlines(label)
    -- Replace \"n with newline characters
    label = label:gsub('\\"n', '\n')
   
     return label
end
end


Line 123: Line 118:
     -- Default to input label if localized string is not found
     -- Default to input label if localized string is not found
     if (key == nil) then
     if (key == nil) then
         return process_newlines(label)
         return label
     end
     end
     if (data_lang[key] == nil) then
     if (data_lang[key] == nil) then
         return process_newlines(label)
         return label
     end
     end


     return process_newlines(data_lang[key])
     -- Replace \"n with newline characters in the result
    local result = data_lang[key]
    result = result:gsub('\\"n', '\n')
   
    return result
end
end


Line 141: Line 140:
          
          
     return lang_code
     return lang_code
end
p.process_newlines = function(text)
    return text:gsub('\\"n', '\n')
end
end


return p
return p