Jump to content

Module:TestLuaIntegration

From Translate

Documentation for this module may be created at Module:TestLuaIntegration/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( "MessageBundleDemoForever" )
  return mb:t( "template-description" )
end

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

function p.testWithoutFallback ()
  local mb = TMB.newWithoutFallbacks( "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