Bikarhêner:Balyozbot/creationrules.js
Zanibe: Piştî weşandinê, ji bo dîtina guhartinan dibe ku hewce be "cache"ya geroka xwe paqij bikî.
- Firefox / Safari: Pê li Shift û Reload bike an jî Ctrl-F5 an Ctrl-R bike (ji bo Mac: ⌘-R)
- Google Chrome: Pê li Ctrl-Shift-R (ji bo Mac: ⌘-Shift-R) bike
- Internet Explorer / Edge: Pê li Ctrl û Refresh bike, an jî Ctrl-F5 bike
- Opera: Pê li Ctrl-F5 bike.
// <nowiki> This prevents the parser from processing the file and generating transclusions and categories for it.
/*Çavkanî: [[en:User:Conrad.Irwin/creationrules.js]]
* 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();
*/
/* jshint maxerr: 600, sub: true */
window.creation_rules = window.creation_rules || {};
// Generate the entry's text
window.generate_entry = function (params)
{
try
{
var param = params.lang;
if (!creation_rules[param])
param = 'others';
if (params.pos == 'cardinal number' || params.pos == 'ordinal number')
pos = 'numeral';
else
pos = params.pos;
var entry = {
pronunc: null,
pos_header: 'Formeke ' + params.pos + 'ê',
head: '{{' + pos + '|' + params.lang + '|' + 'form=erê' + (params.target != params.target_pagename ? '|' + params.target : '') + (params.transliteration ? ('|tr=' + params.transliteration) : '') + '}}',
def: null,
inflection: null,
declension: null,
conjugation: null };
creation_rules[param](params, entry);
return entry;
}
catch (e)
{
if (e instanceof PreloadTextError)
{
console.log(e.message);
return false;
}
else
{
throw e;
}
}
};
// German
creation_rules['de'] =
function (params, entry)
{
entry.def = '{{' + params.form.replace(/-/g, ' ') + ' of|' + params.origin + '|lang=' + params.lang + '}}';
if (params.form == "diminutive")
{
entry.declension = "{{de-decl-noun-n|s}}";
entry.head = "{{de-noun|n|"+params.target+"s|"+params.target+"}}";
}
else if (params.form == "zu")
{
entry.def = '{{de-zu-infinitive of|' + params.origin + '}}';
}
};
// English
creation_rules['en'] =
function (params, entry)
{
switch (params.form)
{
case 'comparative':
entry.head = '{{' + params.pos + '|' + params.lang + '|' + 'form=erê}}';
entry.def = '{{komparatîv|en|' + params.origin + '}}';
break;
case 'superlative':
entry.head = '{{' + params.pos + '|' + params.lang + '|' + 'form=erê}}';
entry.def = '{{sûperlatîv|en|' + params.origin + '}}';
break;
case '3|s|pres':
entry.head = '{{lêker|' + params.lang + '|form=erê}}';
entry.def = '{{en-dema-niha|' + params.origin + '|sêyem|yekjimar}}';
break;
case 'pres|ptcp':
entry.head = '{{lêker|' + params.lang + '|form=erê}}';
entry.def = '{{partîsîpa niha|' + params.lang + '|' + params.origin + '}}';
break;
case 'past':
entry.head = '{{lêker|' + params.lang + '|form=erê}}';
entry.def = '{{en-dema-borî-sade|' + params.origin + '}}';
break;
case 'past|and|past|ptcp':
entry.head = '{{lêker|' + params.lang + '|form=erê}}';
entry.def = '{{en-dema-borî|' + params.origin + '}}';
break;
case 'past|ptcp':
entry.head = '{{lêker|' + params.lang + '|form=erê}}';
entry.def = '{{partîsîpa borî|' + params.lang + '|' + params.origin + '}}';
break;
case 'p':
entry.head = '{{navdêr|' + params.lang + '|form=erê}}';
entry.def = '{{pirjimar|' + params.lang + '|' + params.origin + '}}';
break;
case 'proper-noun-plural':
entry.head = '{{head|' + params.lang + '|proper noun plural form}}';
entry.def = '{{plural of|' + params.origin + '|lang=' + params.lang + '}}';
break;
default:
throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".');
}
};
// Esperanto
creation_rules['eo'] =
function (params, entry)
{
var index = params.origin.indexOf(' de ');
var word = (index != -1)? params.origin.substr(0, index) : params.origin;
var stem = word.substr(0, word.length - 1);
var ending = word.substr(word.length - 1);
if (ending == 'j'){
stem = 'original=' + params.origin + '|';
ending = word.substr(word.length - 2, 1);
}
if (index != -1)
stem = 'original=' + params.origin + '|';
if (ending != 'o' && ending != 'a' && ending != 'i')
throw new PreloadTextError('The Esperanto word "' + params.origin + '" does not end in -o or -a or -i or -oj or -aj (index = ' + index + ', word = ' + word + ', stem = ' + stem + ', ending = ' + ending + ').');
if (ending == 'i')
ending = '';
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' : ''),
'present' :'as',
'past' :'is',
'future' :'os',
'conditional' :'us',
'volitive' :'u',
};
var inflection = formparam[params.form];
if (!inflection)
inflection = params.form;
if (params.pos != 'proper noun')
entry.head = '{{eo-head}}';
// if inflection:match("^[aio]n?t[aeo]$") then
if( inflection.length > 0 && ((inflection.charAt(0) == 'a') || (inflection.charAt(0) == 'i') || (inflection.charAt(0) == 'o')) ){
if( inflection.length > 1 && ((inflection.charAt(1) == 'n')) ){
if( inflection.length > 2 && ((inflection.charAt(2) == 't')) ){
if( inflection.length > 3 && ((inflection.charAt(3) == 'a') || (inflection.charAt(3) == 'e') || (inflection.charAt(3) == 'o')) ){
switch(inflection.charAt(3)){
case 'a':
entry.pos_header = 'Adjective';
break;
case 'e':
entry.pos_header = 'Adverb';
break;
case 'o':
entry.pos_header = 'Noun';
break;
}
entry.head = '{{eo-part}}';
// elseif inflection:match("^[aio]n?t[aeo]j?n?$") then
if( inflection.length > 4 && ((inflection.charAt(4) == 'j'))){
if( inflection.length > 5 && ((inflection.charAt(5) == 'n'))){
entry.head = '{{eo-part-form}}';
}else if( inflection.length == 5 ){
entry.head = '{{eo-part-form}}';
}
}else if( inflection.length > 4 && ((inflection.charAt(4) == 'n'))){
entry.head = '{{eo-part-form}}';
}
}
}
}else{
if( inflection.length > 1 && ((inflection.charAt(1) == 't')) ){
if( inflection.length > 2 && ((inflection.charAt(2) == 'a') || (inflection.charAt(2) == 'e') || (inflection.charAt(2) == 'o')) ){
switch(inflection.charAt(2)){
case 'a':
entry.pos_header = 'Adjective';
break;
case 'e':
entry.pos_header = 'Adverb';
break;
case 'o':
entry.pos_header = 'Noun';
break;
}
entry.head = '{{eo-part}}';
// elseif inflection:match("^[aio]n?t[aeo]j?n?$") then
if( inflection.length > 3 && ((inflection.charAt(3) == 'j'))){
if( inflection.length > 4 && ((inflection.charAt(4) == 'n'))){
entry.head = '{{eo-part-form}}';
}else if( inflection.length == 4 ){
entry.head = '{{eo-part-form}}';
}
}else if( inflection.length > 3 && ((inflection.charAt(3) == 'n'))){
entry.head = '{{eo-part-form}}';
}
}
}
}
}
entry.def = '{{eo-form of|' + stem + '|' + ending + inflection + '}}';
};
// Spanish
creation_rules['es'] =
function (params, entry)
{
var template = {
'plural':'plural of',
'masculine-plural': 'masculine plural of',
'feminine-singular':'feminine singular of',
'feminine-plural': 'feminine plural of'};
if (!template[params.form])
throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".');
entry.def = '{{' + template[params.form] + '|' + params.origin + '|lang=' + params.lang + '}}';
};
// 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 = '{{fa-adj form of|' + formparam[params.form] + '|' + params.origin + '}}';
};
// Finnish
creation_rules['fi'] =
function (params, entry)
{
var headparam = {};
var formparam = {
'plural-nominative':'case=nominative|pl=plural',
'singular-genitive':'case=genitive|pl=singular',
'plural-genitive':'case=genitive|pl=plural',
'singular-partitive':'case=partitive|pl=singular',
'plural-partitive':'case=partitive|pl=plural',
'singular-inessive':'case=inessive|pl=singular',
'plural-inessive':'case=inessive|pl=plural',
'singular-elative':'case=elative|pl=singular',
'plural-elative':'case=elative|pl=plural',
'singular-illative':'case=illative|pl=singular',
'plural-illative':'case=illative|pl=plural',
'singular-adessive':'case=adessive|pl=singular',
'plural-adessive':'case=adessive|pl=plural',
'singular-ablative':'case=ablative|pl=singular',
'plural-ablative':'case=ablative|pl=plural',
'singular-allative':'case=allative|pl=singular',
'plural-allative':'case=allative|pl=plural',
'singular-essive':'case=essive|pl=singular',
'plural-essive':'case=essive|pl=plural',
'singular-translative':'case=translative|pl=singular',
'plural-translative':'case=translative|pl=plural',
'plural-instructive':'case=instructive|pl=plural',
// 'plural-comitative':'case=comitative|pl=plural', // needs alt forms
'singular-abessive':'case=abessive|pl=singular',
'plural-abessive':'case=abessive|pl=plural'};
if (!formparam[params.form])
throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".');
entry.head = '{{head|' + params.lang + '|' + (headparam[params.form] || params.pos + ' form') + '}}';
entry.def = '{{fi-form of|' + params.origin + '|' + formparam[params.form] + '}}';
};
// French
creation_rules['fr'] =
function (params, entry)
{
var template = {
'pirjimar':'pirjimar',
'masculine-plural': 'masculine plural of',
'feminine-singular':'feminine singular 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 == 'navdêr' && params.form == 'forma pirjimar')
entry.head = '{{navdêr|' + params.lang + '|form=erê}}';
entry.def = '{{' + template[params.form] + '|' + params.lang + '|' + params.origin + '}}';
};
// Italian
creation_rules['it'] =
function (params, entry)
{
var template = {
'plural':'plural of',
'masculine-plural': 'masculine plural of',
'feminine-singular':'feminine singular of',
'feminine-plural': 'feminine plural of'};
if (!template[params.form])
throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".');
entry.def = '{{' + template[params.form] + '|' + params.origin + '|lang=' + 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 = '{{head|' + params.lang + '|' + params.pos + ' ' + params.form + ' form}}';
entry.def = '{{' + template[params.form] + (params.pos != 'adjective' ? '|POS=' + params.pos : '') + '|' + params.origin + '|lang=' + params.lang + '}}';
};
// Turkish
creation_rules['tr'] =
function (params, entry)
{
var formparam = {
'definite-plural':'def|p',
'definite-accusative':'def|acc|s',
'plural-definite-accusative':'def|acc|p',
'dative':'dat|s',
'plural-dative':'dat|p',
'locative':'loc|s',
'plural-locative':'loc|p',
'ablative':'abl|s',
'plural-ablative':'abl|p',
'genitive':'def|gen|s',
'plural-genitive':'def|gen|p'};
if (!formparam[params.form])
throw new PreloadTextError('No rule for "' + params.form + '" in language "' + params.lang + '".');
entry.def = '{{inflection of|' + params.origin + '||' + formparam[params.form] + '|lang=' + params.lang + '}}';
};
// Others
creation_rules['others'] =
function (params, entry)
{
params.form = params.form.replace(/-/g, ' ');
params.form += ' of';
entry.def = '{{' + params.form + '|' + params.origin + '|lang=' + params.lang + '}}';
};
// </nowiki>