Jump to content

Module:TestPageLuaIntegration

From translatewiki.net

Documentation for this module may be created at Module:TestPageLuaIntegration/doc

local p = {};

-- Load the Translate lua library
local TMB = require 'mw.ext.translate.messageBundle'

function p.testDefaultLanguage ()
  local mb = mw.ext.translate.messageBundle.new( "User:Abijeet_Patro/MessageBundleDemoForever" )
  return mb:t( "template-description" )
end

function p.testLanguage ()
  local mb = TMB.new( "User:Abijeet_Patro/MessageBundleDemoForever", "es" )
  -- Should fetch Spanish translations, if available, else English
  return mb:t( "description" )
end

function p.testWithoutFallback ()
  local mb = TMB.newWithoutFallbacks( "User:Abijeet_Patro/MessageBundleDemoForever", "fr" )
  -- Since fallbacks are disabled, loads French translation if available else nil
  return mb:t( "description" )
end

-- Simple test function
function p.hello () 
  return 'hello'
end

return p