C# Class i18n.Domain.Concrete.POTranslationRepository

Inheritance: ITranslationRepository
Mostra file Open project: turquoiseowl/i18n Class Usage Examples

Public Methods

Method Description
GetAvailableLanguages ( ) : IEnumerable

Checks in first hand settings file, if not found there it checks file structure

GetCacheDependencyForAllLanguages ( ) : System.Web.Caching.CacheDependency
GetCacheDependencyForSingleLanguage ( string langtag ) : System.Web.Caching.CacheDependency
GetTranslation ( string langtag, List fileNames = null, bool loadingCache = true ) : Translation
POTranslationRepository ( i18nSettings settings ) : System
SaveTemplate ( TemplateItem>.IDictionary items ) : void

Saves a template file which is a all strings (needing translation) used in the entire project. Not language dependent

SaveTranslation ( Translation translation ) : void

Saves a translation into file with standard pattern locale/langtag/message.po Also saves a backup of previous version

TranslationExists ( string langtag ) : bool

Checks if the language is set as supported in config file If not it checks if the PO file is available

Private Methods

Method Description
GetAbsoluteLocaleDir ( ) : string

Gets the locale directory from settings and makes sure it is translated into absolut path

GetPathForLanguage ( string langtag, string filename = null ) : string
ParseBody ( TextReader fs, string line, IEnumerable extractedComments ) : TranslationItem

Parses the body of a PO file item. That is to say the message id and the message itself. Reason for why it must be on second line (textreader) is so that you can read until you have read to far without peek previously for meta data.

ParseTranslationFile ( string langtag, List fileNames, bool loadingCache ) : Translation

Parses a PO file into a Language object

RemoveCommentIfHistorical ( string line ) : string

Removes the preceding characters in a file showing that an item is historical/log. That is to say it has been removed from the project. We don't need care about the character as the fact that it lacks references is what tells us it's a log item

SaveTemplate ( TemplateItem>.IDictionary items, string fileName ) : void
Unescape ( string s ) : string

Looks up in the subject string standard C escape sequences and converts them to their actual character counterparts.

Unquote ( string lhs, string quotechar = "\"" ) : string
WriteString ( StreamWriter stream, bool hasReferences, string type, string value ) : void

Helper for writing either a msgid or msgstr to the po file.

escape ( string s ) : string

Method Details

GetAvailableLanguages() public method

Checks in first hand settings file, if not found there it checks file structure
public GetAvailableLanguages ( ) : IEnumerable
return IEnumerable

GetCacheDependencyForAllLanguages() public method

public GetCacheDependencyForAllLanguages ( ) : System.Web.Caching.CacheDependency
return System.Web.Caching.CacheDependency

GetCacheDependencyForSingleLanguage() public method

public GetCacheDependencyForSingleLanguage ( string langtag ) : System.Web.Caching.CacheDependency
langtag string
return System.Web.Caching.CacheDependency

GetTranslation() public method

public GetTranslation ( string langtag, List fileNames = null, bool loadingCache = true ) : Translation
langtag string
fileNames List
loadingCache bool
return i18n.Domain.Entities.Translation

POTranslationRepository() public method

public POTranslationRepository ( i18nSettings settings ) : System
settings i18nSettings
return System

SaveTemplate() public method

Saves a template file which is a all strings (needing translation) used in the entire project. Not language dependent
public SaveTemplate ( TemplateItem>.IDictionary items ) : void
items TemplateItem>.IDictionary A list of template items to save. The list should be all template items for the entire project.
return void

SaveTranslation() public method

Saves a translation into file with standard pattern locale/langtag/message.po Also saves a backup of previous version
public SaveTranslation ( Translation translation ) : void
translation i18n.Domain.Entities.Translation The translation you wish to save. Must have Language shortag filled out.
return void

TranslationExists() public method

Checks if the language is set as supported in config file If not it checks if the PO file is available
public TranslationExists ( string langtag ) : bool
langtag string The tag for which you want to check if support exists. For instance "sv-SE"
return bool