De la Wikipedia, enciclopedia liber?
Aten?ie!
De?i indepline?te in mare parte acela?i rol ca modulul din alte limbi, acest modul
nu
este o copie a modulului de la en.wp sau din alt? parte. El este scris special pentru necesit??ile Wikipediei in limba roman? ?i nu trebuie inlocuit cu implementarea din alt? parte.
Modulul genereaz? un element HTML
span
care are completat atributul semantic
lang
care identific? un text scris intr-o alt? limb?. El este folosit atat direct, prin formatul
{{
Lang
}}
, cat ?i din alte module.
local
p
=
{}
local
getArgs
=
require
(
'Modul:Arguments'
).
getArgs
local
wikidata
=
require
(
'Modul:Wikidata'
)
p
.
fromArgs
=
function
(
langISOcode
,
languageDir
,
langText
,
italic
)
local
span
=
mw
.
html
.
create
(
'span'
)
span
:
attr
(
'lang'
,
langISOcode
)
span
:
attr
(
'translate'
,
'no'
)
if
languageDir
then
span
:
attr
(
'dir'
,
languageDir
)
end
if
italic
then
span
:
css
(
'font-style'
,
'italic'
)
end
span
:
wikitext
(
langText
)
return
tostring
(
span
)
end
p
.
fromFrame
=
function
(
frame
)
local
args
=
getArgs
(
frame
)
local
langId
=
args
[
1
]
local
langISOCode
=
langId
local
languageRTL
=
args
[
'rtl'
]
local
italic
=
true
if
mw
.
ustring
.
match
(
langId
,
'Q?%d+'
)
then
langISOCode
=
wikidata
.
findOneValue
(
'P218'
,
langId
)
or
wikidata
.
findOneValue
(
'P219'
,
langId
)
or
wikidata
.
findOneValue
(
'P305'
,
langId
)
if
languageAlphabets
and
languageAlphabets
[
1
]
then
languageDirectionalities
=
wikidata
.
getBestEntityIdsList
(
languageAlphabets
[
1
],
'P1406'
)
if
languageDirectionalities
and
languageDirectionalities
[
1
]
then
languageRTL
=
(
languageDirectionalities
[
1
]
==
7333457
)
end
end
end
local
italicarg
=
args
.
italic
or
args
.
i
if
italicarg
==
'no'
or
italicarg
==
'false'
or
italicarg
==
'nu'
or
italicarg
==
'n'
then
italic
=
false
end
return
p
.
fromArgs
(
langISOCode
,
languageRTL
and
'rtl'
,
args
[
2
],
italic
)
end
return
p