User:Jimregan/creationrules.js

//

// This prevents the parser from processing the file and generating transclusions and categories for it.

/* * Language-specific entry generation rules for form-of entries, generated by WT:ACCEL. * * Each function has two parameters. * params holds the parameters given in the template. * entry holds the various parts of the entry to be created. * * The function's task is to provide new values for some of the parts of the new entry. * In most cases, entry.def (the definition line) will be overridden, but the headword (entry.head) * or even the part-of-speech or language headers can be overridden if necessary. * * If the function is not able to handle the current form for whatever reason, throw an exception: * throw new PreloadTextError; */

window.creation_rules = {};

// Generate the entry's text window.get_preload_text = function (params) {	try {		if (!creation_rules[params.lang]) return false; var entry = { lang_header: ' Lua error in Module:languages/templates at line 28: The language code "' + params.lang + '" is not valid. ',			pronunc: null, pos_header: params.pos.charAt(0).toUpperCase + params.pos.substr(1), head: '', def: null, declension: null, conjugation: null }; creation_rules[params.lang](params, entry); entry_text = '==' + entry.lang_header + '==' + (entry.pronunc ? '\n\n===Pronunciation===\n' + entry.pronunc : '') + '\n\n===' + entry.pos_header + '===' + '\n' + entry.head + '\n\n' + '# ' + entry.def + (entry.declension ? '\n\n====Declension====\n' + entry.declension : '') + (entry.conjugation ? '\n\n====Conjugation====\n' + entry.conjugation : ''); return entry_text; }	catch (e) {		if (e instanceof PreloadTextError) {			console.log(e.message); return false; }		else {			throw e;		} } }

// Afrikaans creation_rules['af'] = function (params, entry) {		var template = { 'plural':'plural of', 'diminutive': 'diminutive of', 'present-participle':'present participle of', 'past-participle':'past participle of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); switch (params.form) {			case 'plural': entry.head = ''; break; case 'diminutive': entry.head = ''; break; default: entry.head = ''; }		entry.def = ''; };

// Asturian creation_rules['ast'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of', 'neuter':'neuter of', };		if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Azeri creation_rules['az'] = function (params, entry) {		var formparam = { 'definite-plural':'definite|p', 'definite-accusative':'definite|acc|s', 'plural-definite-accusative':'definite|acc|p', 'dative':'dat|s', 'plural-dative':'dat|p', 'locative':'loc|s', 'plural-locative':'loc|p', 'ablative':'abl|s', 'plural-ablative':'abl|p', 'genitive':'definite|gen|s', 'plural-genitive':'definite|gen|p'}; if (!formparam[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; }

// Bulgarian creation_rules['bg'] = function (params, entry) {		var formparam = { 'singular-definite':'singular|definite', 'singular-definite-subject':'singular|definite|subject', 'singular-definite-object':'singular|definite|object', 'plural-indefinite': 'plural|indefinite', 'plural-definite': 'plural|definite', 'count': 'count', 'vocative': 'vocative'}; if (!formparam[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; }

// Catalan creation_rules['ca'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Mandarin pinyin creation_rules['cmn'] = function (params, entry) {		switch (params.form) {			case 'pinyin-ts': entry.pos_header = 'Romanization'; entry.head = ''; entry.def = ''; break; case 'pinyin-t': entry.pos_header = 'Romanization'; entry.head = ''; // the simplified form is passed through the gender parameter entry.def = ''; break; case 'pinyin-s': entry.pos_header = 'Romanization'; entry.head = ''; // the traditional form is passed through the gender parameter entry.def = ''; break; default: throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); }	};

// Danish creation_rules['da'] = function (params, entry) {		var template = { 'singular-definite':'singular definite of', 'plural-indefinite': 'plural indefinite of', 'plural-definite': 'plural definite of', 'genitive-singular-indefinite':'genitive singular definite of', 'genitive-singular-definite':'genitive singular definite of', 'genitive-plural-indefinite': 'genitive plural indefinite of', 'genitive-plural-definite': 'genitive plural definite of', 'imperative':'imperative of', 'present':'present tense of', 'past':'past tense of', 'past-participle':'past participle of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; }

// German creation_rules['de'] = function (params, entry) {		entry.def = ''; };

// English creation_rules['en'] = function (params, entry) {		switch (params.form) {			case 'comparative': entry.head = ''; entry.def = ''; break; case 'superlative': entry.head = ''; entry.def = ''; break; case 'third-person-singular': entry.head = ''; entry.def = ''; break; case 'present-participle': entry.head = ''; entry.def = ''; break; case 'simple-past': entry.head = ''; entry.def = ''; break; case 'simple-past-and-participle': entry.head = ''; entry.def = ''; break; case 'past-participle': entry.head = ''; entry.def = ''; break; case 'plural': entry.head = ''; entry.def = ''; break; default: throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); }	};

// Esperanto creation_rules['eo'] = function (params, entry) {		var stem = params.origin.substr(0, params.origin.length - 1); var ending = params.origin.substr(params.origin.length - 1); if (ending != 'o' && ending != 'a') throw new PreloadTextError('The Esperanto word "' + params.origin + '" does not end in -o or -a.'); var formparam = { 'uncountable-accusative':'n|unc=yes', 'plural'               :'j' + (params.pos == 'proper noun' ? '-proper' : ''), 'accusative'           :'n' + (params.pos == 'proper noun' ? '-properpl' : ''), 'accusative-plural'    :'jn' + (params.pos == 'proper noun' ? '-properpl' : '')}; if (!formparam[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos != 'proper noun') entry.head = ''; entry.def = ''; };

// Spanish creation_rules['es'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Persian creation_rules['fa'] = function (params, entry) {		var formparam = { 'comparative':'c', 'superlative':'s'}; if (!formparam[params.form] || params.pos != 'adjective') throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// French creation_rules['fr'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Middle French creation_rules['frm'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Irish creation_rules['ga'] = function (params, entry) {		switch (params.form) {			case 'plural': entry.def = ''; break; case 'genitive': entry.def = ''; break; case 'genitive-and-plural': entry.def = '' +					'\n# '; break; default: throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); }	};

// Scottish Gaelic creation_rules['gd'] = function (params, entry) {		switch (params.form) {			case 'plural': entry.def = ''; break; case 'genitive': entry.def = ''; break; case 'genitive-and-plural': entry.def = '' +					'\n# '; break; default: throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); }	};

// Galician creation_rules['gl'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Manx creation_rules['gv'] = function (params, entry) {		var template = { 'plural':'plural of', 'genitive':'genitive of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Hebrew creation_rules['he'] = function (params, entry) {		var formparam = { 'plural':'|n=p|s=i', 'construct':'|n=s|s=c', 'plural-construct':'|n=p|s=c'}; if (!formparam[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Hungarian creation_rules['hu'] = function (params, entry) {		if (params.form == 'comparative' || params.form == 'superlative') {			entry.head = ''; entry.def = ''; }		else {			var formparam = { 'nominative-singular' : 'nom|s', 'accusative-singular' : 'acc|s', 'dative-singular' : 'dat|s', 'instrumental-singular' : 'ins|s', 'causal-final-singular' : 'cfin|s', 'translative-singular' : 'tran|s', 'terminative-singular' : 'term|s', 'essive-formal-singular' : 'efor|s', 'essive-modal-singular' : 'emod|s', 'inessive-singular' : 'ine|s', 'superessive-singular' : 'sup|s', 'adessive-singular' : 'ade|s', 'illative-singular' : 'ill|s', 'sublative-singular' : 'sub|s', 'allative-singular' : 'all|s', 'elative-singular' : 'ela|s', 'delative-singular' : 'del|s', 'ablative-singular' : 'abl|s', 'nominative-plural' : 'nom|p', 'accusative-plural' : 'acc|p', 'dative-plural' : 'dat|p', 'instrumental-plural' : 'ins|p', 'causal-final-plural' : 'cfin|p', 'translative-plural' : 'tran|p', 'terminative-plural' : 'term|p', 'essive-formal-plural' : 'efor|p', 'essive-modal-plural' : 'emod|p', 'inessive-plural' : 'ine|p', 'superessive-plural' : 'sup|p', 'adessive-plural' : 'ade|p', 'illative-plural' : 'ill|p', 'sublative-plural' : 'sub|p', 'allative-plural' : 'all|p', 'elative-plural' : 'ela|p', 'delative-plural' : 'del|p', 'ablative-plural' : 'abl|p' };			if (!formparam[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; }	};

// Ido creation_rules['io'] = function (params, entry) {		var template = { 'plural':'plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Japanese creation_rules['ja'] = function (params, entry) {		switch (params.form) {			case 'romanized': entry.pos_header = 'Romanization'; entry.head = ''; entry.def = ''; break; case 'kana-noun': entry.pos_header = 'Noun'; entry.head = ''; entry.def = ' '; break; case 'kana-proper-noun': entry.pos_header = 'Proper noun'; entry.head = ''; entry.def = ' '; break; case 'kana-verb': entry.pos_header = 'Verb'; entry.head = ''; entry.def = ' '; break; case 'kana-adjective': entry.pos_header = 'Adjective'; entry.head = ''; entry.def = ' '; break; case 'kana-adverb': entry.pos_header = 'Adverb'; entry.head = ''; entry.def = ' '; break; default: throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); }	};

// Kurdish creation_rules['ku'] = function (params, entry) {		var template = { 'comparative':'comparative of', 'superlative':'superlative of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.head = ''; entry.def = ''; };

// Classical Nahuatl creation_rules['nci'] = function (params, entry) {		var template = { 'plural':'plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.head = ''; entry.def = ''; };

// Dutch creation_rules['nl'] = function (params, entry) {		switch (params.form) {			case 'plural': entry.head = ''; entry.def = ''; break; case 'diminutive': entry.head = ''; entry.def = ''; break; default: throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); }	};

// Norwegian creation_rules['no'] = function (params, entry) {		var template = { 'singular-definite':'singular definite of', 'plural-indefinite': 'plural indefinite of', 'plural-definite': 'plural definite of', 'genitive-singular-indefinite':'genitive singular definite of', 'genitive-singular-definite':'genitive singular definite of', 'genitive-plural-indefinite': 'genitive plural indefinite of', 'genitive-plural-definite': 'genitive plural definite of', 'imperative':'imperative of', 'present':'present tense of', 'past':'past tense of', 'past-participle':'past participle of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; }

// Bokmål and Nynorsk creation_rules['nb'] = creation_rules['no'] creation_rules['nn'] = creation_rules['no']

// Occitan creation_rules['oc'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Polish creation_rules['pl'] = function (params, entry) {		var template = { 'comparative':'comparative of', 'superlative':'superlative of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.head = ''; entry.def = ''; entry.pronunc = '* '; if (params.pos === 'adjective') entry.declension = '' };

// Portuguese creation_rules['pt'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Romansch creation_rules['rm'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Romanian creation_rules['ro'] = function (params, entry) {		var template = { 'plural':'plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Gallo creation_rules['roa-gal'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Guernésiais creation_rules['roa-grn'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Jèrriais creation_rules['roa-jer'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Norman creation_rules['roa-nor'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Russian creation_rules['ru'] = function (params, entry) {		var template = { 'comparative':'comparative of', }		if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'adverb' && params.form == 'comparative') entry.head = ''; entry.def = ''; }

// Sicilian creation_rules['scn'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Slovene creation_rules['sl'] = function (params, entry) {		switch (params.form) {			case 'comparative': case 'superlative': entry.pronunc = ''; entry.head = ''; // If there is a comma in the head, assume it has multiple accented variants. // Add a link with an alternative display form instead. entry.def = '';				// If it's an adjective, add a declension table if (params.pos == 'adjective') {					var stem = params.target.substr(0, params.target.length - 1); var ending = params.target.substr(params.target.length - 1); // Adjective comparatives and superlatives must always end in -i if (ending != 'i') throw new PreloadTextError('The Slovene comparative/superlative "' + params.target + '" does not end in -i.'); entry.declension = ''; }				break; default: throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); }	}

// Swedish creation_rules['sv'] = function (params, entry) {		var template = { 'positive/n':'sv-adj-form-abs-indef-n', 'positive/m':'sv-adj-form-abs-def-m', 'positive-definite/':'sv-adj-form-abs-def', 'positive-plural/':'sv-adj-form-abs-pl', 'comparative/':'sv-' + (params.pos == 'adjective' ? 'adj' : 'adv') + '-form-comp', 'superlative-attributive/m':'sv-adj-form-sup-attr-m', 'superlative-attributive-definite/':'sv-adj-form-sup-attr', 'superlative-attributive-plural/':'sv-adj-form-sup-attr-pl', 'superlative-predicative/':'sv-adj-form-sup-pred', 'superlative/':'sv-adv-form-sup'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; }

// Swahili creation_rules['sw'] = function (params, entry) {		var template = { 'plural':'plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.head = ''; entry.def = ''; };

// Tajik creation_rules['tg'] = function (params, entry) {		var formparam = { 'comparative':'c', 'superlative':'s'}; if (!formparam[params.form] || params.pos != 'adjective') throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; };

// Turkish creation_rules['tr'] = function (params, entry) {		var formparam = { 'definite-plural':'definite|p', 'definite-accusative':'definite|acc|s', 'plural-definite-accusative':'definite|acc|p', 'dative':'dat|s', 'plural-dative':'dat|p', 'locative':'loc|s', 'plural-locative':'loc|p', 'ablative':'abl|s', 'plural-ablative':'abl|p', 'genitive':'definite|gen|s', 'plural-genitive':'definite|gen|p'}; if (!formparam[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); entry.def = ''; }

// Venetian creation_rules['vec'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Walloon creation_rules['wa'] = function (params, entry) {		var template = { 'plural':'plural of', 'masculine-plural': 'masculine plural of', 'feminine':'feminine of', 'feminine-plural': 'feminine plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Vilamovian creation_rules['wym'] = function (params, entry) {		var template = { 'plural':'plural of', 'diminutive':'diminutive of', 'masculine-plural': 'masculine plural of', 'feminine-plural': 'feminine plural of', 'neuter-plural': 'neuter plural of'}; if (!template[params.form]) throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); if (params.pos == 'noun' && params.form == 'plural') entry.head = ''; entry.def = ''; };

// Yiddish creation_rules['yi'] = function (params, entry) {		switch (params.form) {			case 'plural': entry.head = ''; entry.def = ''; break; case 'past-participle': entry.head = ''; entry.def = ''; break; default: throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".'); }	};

//