Skip to content

josecuellar/dotnet-languageparser-pagebasetype

Repository files navigation

Very simple language translation and HTML Cleaner for MVC

The library get text of your HTML for translate to all languages configured and clean unnecesary formats on the fly.

Configuration:

    <add key="TranslateEnabled" value="true"/> -> Enable text translation on the fly
    <add key="ClearCommentsAndUnnecesaryFormat" value="true"/> -> Clear and compress HTML
    <add key="SavePendingTranslations" value="true"/> --> Save pending text translations
    <add key="DefaultLanguageOfKeys" value="es-ES"/> --> Your default current culture

Implement your custom providers and parsers for translations dictionary.
JSON is by Default. Create all JSON file by language:

-- ca-ES.json
-- en-GB.json

Example of content. Keys are the default text in default language culture configured:

{
  "Inicio": "Inici",
  "Bienvenido": "Benvingut",
  "Proyecto demo": "Projecte demo"
}

Specify the language to translate in action controller:

	//System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("ca-ES");
    System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-GB");

All pending translations not founded, save automatically in the same location to json files with the next format:

-- ca-ES.Pending.json

Example of content:

{
  "Ejemplo 1": "write translation and move element to ca-ES.json",
  "Ejemplo 1 texto.": "write translation and move element to ca-ES.json",
}

Only need replace in Views\web.config the next line:

    <!--<pages pageBaseType="System.Web.Mvc.WebViewPage">-->
    <pages pageBaseType="LanguageParser.PageBaseType">



Feel free for fork and contribute!
Thanks!

About

Parsing text into html response for transform to different languages

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published