User:Dixtosa/langmetadataproject
Appearance
new design
[edit]Have two classes one to query all possible data (good for autocomplete) and one to fetch all data for one language.
Problems
[edit]- genders
has wiktionaryWikimediaPrefix- hardcode meta:Special_language_codes and use new mw.ForeignApi("https://"+overridden_langcode+".wiktionary.org/w/api.php")
- has noun clasess
it is probably best to define them in Lua rather than js?
class Language
{
//FIELDS
public boolean HasWiktionary;
public string[] scripts;
public string WikimediaPrefix;
public string[] Genders;
public boolean HasNounClasses;
public boolean CanAutoTransliterate; //NEW
//OPERATIONS
CreateFromLangCode(langCode);
CreateFromCanonicalName(canonicalName);
GuessScript(term);
GuessScript();
HasWiktionary();
}
class LanguageRepository
{
public constructor(boolean isLazyRepository)
{
loadAllDataForAllLanguages();
}
HasWiktionary(langCode); //implementation note: only keep those that have (200 vs 2000?)
}
New functions needed
[edit]- Search languages by their canonical or alternative names (for autocomplete)
old interface
[edit]class LangMetaData{
//Returns true if a Wiktionary exists for the specified language
public boolean HasWiktionary(langCode);
//Returns the domain-name prefix of the Wiktionary for the specified language
public string GetWiktionaryPrefix (langCode);
// Calls the callback with a boolean indicating whether the specified language
// has a Wiktionary with the specified entry. The callback might be called
// synchronously, or it might be called asynchronously.
public void HasWiktionaryWithEntry(langCode, title, callback?);
//Given a language code return a default script code.
public string GuessScript (langCode);
// In a given language, would we expect a translation of the title to have the capitalisation
// of word?
public boolean ExpectedCase (langCode, title, word);
//Returns a string of standard gender letters (mfnc) or an empty string
public string GetGenders = function(lang)
//Returns a string of standard noun class numbers or an empty string
public string HasNounClasses = function(lang)
//Returns true if the specified lang uses optional vowels or diacritics
public boolean NeedsRawPageName(lang);
// Computes the raw page name by removing diacritics (for Latin, etc.)
public ComputeRawPageName(lang, word);
// Calls [[Module:links]]'s 'remove_diacritics' method on word and rawPageName,
// and invokes callback with two arguments: (1) the *real* raw page name
// (superseding even rawPageName), and (2) whether this real raw page name
// needs to be explicitly specified in the wikitext (i.e., whether the raw page
// name computed from rawPageName is different from the one that would have been
// computed from just word).
public RetrieveRawPageName(lang, word, rawPageName, callback?);
//Given user input, return a language code. Normalises ISO 639-1 codes and names to 639-3.
public string CleanLangCode(lang);
// Get the nesting for a given sub-language
public GetNested = function (lang)
public temporalSortKey(langname);
// For enforcing an ordering on nested languages.
public NestsBefore (a, b);
public GetScripts (lang);
}