Module:TranslatedCat

local exports = {}

-- For the provided language code's primary subtag (the portion before hyphen), -- this will return the name of its sub-category function exports.getPrimaryCat(frame) local langCode = frame.args[1] local primaryCode = langCode:match('^%a+') local primaryName = mw.language.fetchLanguageName(primaryCode)

-- The primary language name is used as parent category when the -- language code ('pt-BR') and its primary code ('pt') differ, -- and when the primary is a recognised language itself (some   -- primary codes are only for language collectives, e.g. 'roa') if langCode ~= primaryCode and primaryName ~= '' then return '/' .. primaryName end

-- No parent category return '' end

return exports