<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ar">
	<id>https://3rabica.org/index.php?action=history&amp;feed=atom&amp;title=%D9%88%D8%AD%D8%AF%D8%A9%3ALanguage%2Ftext</id>
	<title>وحدة:Language/text - تاريخ المراجعة</title>
	<link rel="self" type="application/atom+xml" href="https://3rabica.org/index.php?action=history&amp;feed=atom&amp;title=%D9%88%D8%AD%D8%AF%D8%A9%3ALanguage%2Ftext"/>
	<link rel="alternate" type="text/html" href="https://3rabica.org/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:Language/text&amp;action=history"/>
	<updated>2026-06-04T20:26:51Z</updated>
	<subtitle>تاريخ التعديل لهذه الصفحة في الويكي</subtitle>
	<generator>MediaWiki 1.43.7</generator>
	<entry>
		<id>https://3rabica.org/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:Language/text&amp;diff=1084&amp;oldid=prev</id>
		<title>عبد العزيز: أنشأ الصفحة ب&#039;--[[ -- This module is a replacement for {{lang}} and all lang-x templates. -- It wraps text in an HTML tag containing a lang attribute with a specific -- language code....&#039;</title>
		<link rel="alternate" type="text/html" href="https://3rabica.org/index.php?title=%D9%88%D8%AD%D8%AF%D8%A9:Language/text&amp;diff=1084&amp;oldid=prev"/>
		<updated>2016-12-01T13:29:16Z</updated>

		<summary type="html">&lt;p&gt;أنشأ الصفحة ب&amp;#039;--[[ -- This module is a replacement for {{lang}} and all lang-x templates. -- It wraps text in an HTML tag containing a lang attribute with a specific -- language code....&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;صفحة جديدة&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
-- This module is a replacement for {{lang}} and all lang-x templates.&lt;br /&gt;
-- It wraps text in an HTML tag containing a lang attribute with a specific&lt;br /&gt;
-- language code. This often makes no visible changes to the text, but can help&lt;br /&gt;
-- web browsers choose the right font, screen readers use the right&lt;br /&gt;
-- pronunciation and more. The plain function wraps the text in the HTML tag,&lt;br /&gt;
-- but does not otherwise change the output. The named function adds the name of&lt;br /&gt;
-- the language before the text.&lt;br /&gt;
--]]&lt;br /&gt;
&lt;br /&gt;
-- Load required modules.&lt;br /&gt;
local mLanguageName = require(&amp;quot;Module:Language/name&amp;quot;)&lt;br /&gt;
local yesno = require(&amp;quot;Module:Yesno&amp;quot;)&lt;br /&gt;
local libraryUtil = require(&amp;#039;libraryUtil&amp;#039;)&lt;br /&gt;
local checkType = libraryUtil.checkType&lt;br /&gt;
local data = mw.loadData(&amp;quot;Module:Language/data/wp languages&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- Lazily initialise [[Module:Arguments]], as we will only need it sometimes.&lt;br /&gt;
-- Not loading it when we don&amp;#039;t have to will keep its transclusion count down,&lt;br /&gt;
-- which helps to reduce load on the job queue.&lt;br /&gt;
local mArguments&lt;br /&gt;
&lt;br /&gt;
-- The p table contains functions that will be available from #invoke and that&lt;br /&gt;
-- will be available to other Lua modules (including for use in the test cases).&lt;br /&gt;
-- The f table contains functions linking #invoke functions to Lua functions.&lt;br /&gt;
local p, f = {}, {}&lt;br /&gt;
&lt;br /&gt;
function f.plain(code, text, options)&lt;br /&gt;
	checkType(&amp;quot;plain&amp;quot;, 1, code, &amp;quot;string&amp;quot;)&lt;br /&gt;
	checkType(&amp;quot;plain&amp;quot;, 2, text, &amp;quot;string&amp;quot;)&lt;br /&gt;
	checkType(&amp;quot;plain&amp;quot;, 3, options, &amp;quot;table&amp;quot;, true)&lt;br /&gt;
	options = options or {}&lt;br /&gt;
	local name = p._fetchLanguageName(code)&lt;br /&gt;
	if not name then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	return p._createElement(code, text, name, options)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function f.named(code, text, options)&lt;br /&gt;
	checkType(&amp;quot;named&amp;quot;, 1, code, &amp;quot;string&amp;quot;)&lt;br /&gt;
	checkType(&amp;quot;named&amp;quot;, 2, text, &amp;quot;string&amp;quot;)&lt;br /&gt;
	checkType(&amp;quot;named&amp;quot;, 3, options, &amp;quot;table&amp;quot;, true)&lt;br /&gt;
	options = options or {}&lt;br /&gt;
	local name = p._fetchLanguageName(code)&lt;br /&gt;
	if not name then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	return string.format(&lt;br /&gt;
		&amp;quot;[[%s language|%s]]: %s&amp;quot;,&lt;br /&gt;
		name,&lt;br /&gt;
		name,&lt;br /&gt;
		p._createElement(code, text, name, options)&lt;br /&gt;
	)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._fetchLanguageName(code)&lt;br /&gt;
	-- Fetches a language name, given a language code. If no name can be&lt;br /&gt;
	-- found, returns nil.&lt;br /&gt;
	if not code then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	local name = mLanguageName.fuzzy{code = code}&lt;br /&gt;
	if name and name ~= &amp;quot;&amp;quot; then&lt;br /&gt;
		return name&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._createElement(code, text, name, options)&lt;br /&gt;
	-- Creates the HTML element.&lt;br /&gt;
	-- Check whether a preferred code is specified in the Wikipedia language&lt;br /&gt;
	-- data for the input code we are given.&lt;br /&gt;
	code = data[code] and data[code][2]	or code&lt;br /&gt;
	local tag = options.tagName or &amp;quot;span&amp;quot;&lt;br /&gt;
	local root = mw.html.create(tag)&lt;br /&gt;
	root&lt;br /&gt;
		:attr(&amp;quot;lang&amp;quot;, code)&lt;br /&gt;
		:wikitext(text .. p._categorise(code, name, options))&lt;br /&gt;
	return tostring(root)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._categorise(code, name, options)&lt;br /&gt;
	-- Generates the tracking category.&lt;br /&gt;
&lt;br /&gt;
	local function makeCategory(cat)&lt;br /&gt;
		-- Makes a category wikilink.&lt;br /&gt;
		return string.format(&amp;quot;[[%s:%s]]&amp;quot;, mw.site.namespaces[14].name, cat)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local function makeTitle(...)&lt;br /&gt;
		-- Get a title object, using pcall to call mw.title.new to&lt;br /&gt;
		-- avoid producing script errors. mw.title.new will result&lt;br /&gt;
		-- in a script error if we are over the expensive function count&lt;br /&gt;
		-- limit, among other fun and exciting scenarios.&lt;br /&gt;
		local success, title = pcall(mw.title.new, ...)&lt;br /&gt;
		if success then&lt;br /&gt;
			return title&lt;br /&gt;
		else&lt;br /&gt;
			return nil&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Don&amp;#039;t categorise if nocat is set.&lt;br /&gt;
	if yesno(options.nocat, true) then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	--[[&lt;br /&gt;
	-- Don&amp;#039;t categorise if we are not on a content page.&lt;br /&gt;
	-- Allow specification of options.page so that this function can be&lt;br /&gt;
	-- tested as if it were being run on different pages. This option&lt;br /&gt;
	-- isn&amp;#039;t provided for Lua functions as it would probably not be used&lt;br /&gt;
	-- and would decrease performance slightly.&lt;br /&gt;
	--]]&lt;br /&gt;
	local titleObj = options.page&lt;br /&gt;
		and makeTitle(options.page)&lt;br /&gt;
		or mw.title.getCurrentTitle()&lt;br /&gt;
	if not titleObj or not titleObj.isContentPage then&lt;br /&gt;
		return &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Assemble the category.&lt;br /&gt;
	if code == &amp;quot;en&amp;quot; or code == &amp;quot;eng&amp;quot; then&lt;br /&gt;
		return makeCategory(&lt;br /&gt;
			&amp;quot;Articles containing explicitly cited English-language text&amp;quot;&lt;br /&gt;
		)&lt;br /&gt;
	else&lt;br /&gt;
		local categoryName = &amp;quot;Articles containing &amp;quot;&lt;br /&gt;
			.. name&lt;br /&gt;
			.. &amp;quot;-language text&amp;quot;&lt;br /&gt;
		local categoryTitle = makeTitle(categoryName, 14)&lt;br /&gt;
		if categoryTitle and categoryTitle.exists then&lt;br /&gt;
			return makeCategory(categoryName)&lt;br /&gt;
		else&lt;br /&gt;
			return makeCategory(&lt;br /&gt;
				&amp;quot;Articles containing non-English-language text&amp;quot;&lt;br /&gt;
			)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
--[=[&lt;br /&gt;
-- Make the #invoke functions. The function names are taken from the f table.&lt;br /&gt;
-- The #invoke function is named p.funcName, and the function it calls is named&lt;br /&gt;
-- f.funcName. If the result of f.funcName(args) is nil, then p.funcName&lt;br /&gt;
-- returns the blank string. This allows for use of both Lua-like and&lt;br /&gt;
-- wikitext-like idioms should any of the validation checks fail. We use&lt;br /&gt;
-- [[Module:Arguments]] to get the arguments from the frame object. We also&lt;br /&gt;
-- make the f.funcName functions available to other Lua modules under the name&lt;br /&gt;
-- p._funcName.&lt;br /&gt;
--]=]&lt;br /&gt;
for funcName, func in pairs(f) do&lt;br /&gt;
	p[funcName] = function (frame)&lt;br /&gt;
		mArguments = require(&amp;quot;Module:Arguments&amp;quot;)&lt;br /&gt;
		local args = mArguments.getArgs(frame)&lt;br /&gt;
		-- Get the code and text variables.&lt;br /&gt;
		local code = args.code&lt;br /&gt;
		local text = args.text&lt;br /&gt;
		if not code or not text then&lt;br /&gt;
			-- Give up gracefully if we don&amp;#039;t have the required input.&lt;br /&gt;
			return text or &amp;quot;&amp;quot;&lt;br /&gt;
		end&lt;br /&gt;
		-- Pass values through to the options table.&lt;br /&gt;
		local options = {}&lt;br /&gt;
		options.tagName = args.type&lt;br /&gt;
		options.nocat = args.nocat&lt;br /&gt;
		return f[funcName](code, text, options) or &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
	-- Create the function to access from other Lua modules.&lt;br /&gt;
	p[&amp;quot;_&amp;quot; .. funcName] = func&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>عبد العزيز</name></author>
	</entry>
</feed>