Giter VIP home page Giter VIP logo

txtranslation's Introduction

Tx Translation & Localisation for .NET and WPF

See http://unclassified.software/source/txtranslation for further information.

About TxTranslation

Tx is a simple yet powerful translation and localisation library for .NET applications. It manages a dictionary containing all the text snippets and phrases you need, for multiple translations. If a translation is not available in your preferred language, it can be looked up from other languages. Texts can also contain named place-holders that are filled with your data at runtime so that you don’t need to concatenate all the parts yourself in the right order. Localisation tasks like typography, number or time formatting according to the local standards are also covered.

A special feature of Tx dictionaries is that each text can have different translations depending on the subject count you’re talking about. One “day” is a different word than two “days”. This allows you to speak to your users in the most natural way, avoiding ugly parentheses or alternatives for plural words in the user interface.

All texts and translations are stored in an XML dictionary file, one per project. This XML file usually contains all languages. The dictionary can be installed with your application, or compiled right into it as an embedded resource.

The TxLib library can be used from any .NET application and is the part you’ll distribute with your application. For more portable applications, you could also directly copy the class files into your project – it’s only a few files. Its main class, Tx, is further described in the documentation.

Text keys

All texts are associated with text keys. A text key is a short string that uniquely identifies a text or phrase and is usually used in the application source code to refer to a specific text. Text keys can be freely assigned by the developer, but there are some structuring guidelines described at the end of the documentation and a few additional requirements when using the TxEditor tool.

Cultures

The .NET framework uses the concept of cultures to specify a combination of language and data formatting rules. Each culture has a code that describes the language and optionally a region. There are more variants but they are not supported by TxLib. Examples are “en” for the English language, “de-DE” for the German language in Germany or “pt-BR” for the Portuguese language in Brasil (as opposed to Portugal which many would probably first think of). TxLib uses these cultures to identify translations and both, region-specific and language-only codes, are used where the latter ones always serve as fallback if a translation is not found for a specific culture.

TxEditor

The TxTranslation solution also comes with a graphical translation file editor that provides all the functionality for translating personnel that don’t necessarily have any programming experience. The TxEditor application can load a dictionary file, list all the text keys that it defines and allows viewing and editing the translation texts. It performs consistency checks to point the user to potential errors and highlight missing translations. TxEditor also makes use of TxLib itself so it is fully localisable and can be used to translate itself into other languages.

Licence

The TxLib library, which is used in applications, is released under the terms of the GNU Lesser GPL (LGPL) licence, version 3.

The other projects (TxEditor, demos and converters) are released under the terms of the GNU GPL licence, version 3.

You can find the detailed terms and conditions in the download or on the GNU website http://www.gnu.org/licenses/lgpl-3.0.html and http://www.gnu.org/licenses/gpl-3.0.html.

txtranslation's People

Contributors

blackgad avatar ygoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

txtranslation's Issues

Portable version of TxTranslation

First of all thank a lot for the great, convenient and awesome library! It is perfect!
Unfortunately it can not be applied to mobile development Xamarin Forms for example. And it is very sad
Have you plan port it in cross-platform PLC library ?

Accepting inconsistency in TxEditor changes behavior in translation

I'm not sure if this behavior is intentional, but it is not how I understood the documentation.

Say you have a txd file with English (as primary) and French cultures, and a key that intentionally only has a translation for english:

<?xml version="1.0" encoding="utf-8"?>
<!-- TxTranslation dictionary file. Use TxEditor to edit this file. http://unclassified.software/txtranslation -->
<translation xml:space="preserve">
	<culture name="en" primary="true">
		<text key="minimum" comment="The english translation works also for french">Min</text>
	</culture>
	<culture name="fr" />
</translation>

Then Tx.SetCulture("fr"); Tx.T("minimum"); would result in "Min" as intended.

The TxEditor shows a "Missing translation" as a problem for that key, so you click on that (so it gets a green checkmark) to accept the inconsistency and mark it as intentional. This results in:

<?xml version="1.0" encoding="utf-8"?>
<!-- TxTranslation dictionary file. Use TxEditor to edit this file. http://unclassified.software/txtranslation -->
<translation xml:space="preserve">
	<culture name="en" primary="true">
		<text key="minimum" comment="The english translation works also for french">Min</text>
	</culture>
	<culture name="fr">
		<text key="minimum" acceptmissing="true" />
	</culture>
</translation>

With that file, the behavior is now different, and Tx.SetCulture("fr"); Tx.T("minimum"); results in an empty string.
I expected this to only affect the behavior in the TxEditor, not the actual translation.

Use dictionary file with project?

What am I missing, the documentation does not contain an actual guide on how to set up so I had to feel around in the dark. I have the library and am correctly (i think) trying to translate a peice of text using <TextBlock Text="{Tx:T Announcements}"/> I also created and saved a dictionary to my bin/debug folder called localization.txd, but how do I actually tie this dictionary to my project?

.NET Standard / .Net Core

Do you plan on supporting .Net Standard / .Net Core? I am currently using your software (love it BTW), but need to convert my software to .Net Standard. Will you be updating the nuget package to contain a .Net Standard build?

Thanks.

TxEditor

Features that i require:

  1. Multiple dictionary files editing.
  2. UI improvement(arguments description for specific key etc)
  3. Drag'n'drop support tree
  4. Partial key templates for common element description (commands, forms etc)

So I must to decide what to do:

  1. Rework UI core (I am afraid that it will broke backward compatibility with your current master state or pull requests will be huge)
  2. Add this features externally with out core rewriting (add additional pane for multiple files).

I will choose 2 if you interested in your master Editor improvement. If you do not care about requested features I will choose 1.

Dictionary gets purged when another assembly gets loaded

TxLib stores its translations in a static dictionary. Imagine you have your application A.exe that uses TxLib.dll version A. Now A.exe has plugin support and can be enriched by the plugin B.dll. B.dll uses another version of TxLib.dll version B.
The second the plugin reaches a method that access the static Tx.T fuction (or any other static function) TxLib.dll version B will get loaded and the static class constructor will initialize the static dictionary. This leads to a loss of translations for the loaded assembly TxLib.dll version A.

This issue is so apparent it even sometimes breaks unit tests that run in parallel, all using TxLib: In the instance another test accesses the static Tx.T function (or any other) the test itself cannot access the translation any longer.

I propose to add a non-static constructor and non static functions. Then the translation objects can live next to each other. For backward compatibility one could offer a static Default TxLib object, that uses the same non-static ctor and all static functions use that (static) instance.

.txd file is not reloaded when saved with TxEditor

Hi! Great project :)

I have the problem with updating *.txd file via TxEditor.
When i update it via TxEditor, MainWindow.xaml form of project WpfDemo doesn't update.
If i do it via any text editor (e.g. notepad++) it works.
Could you help me with this problem?

Dictionary from embedded resource gets lost when using filewatchers

Hi,

we are loading dictionaries from both an embedded resource and from XML files.
The embedded resource acts as a fallback when the user does not provide a complete txd file.

When we have Tx.UseFileSystemWatcher = true, and modify a txd file, the keys from the embedded resource get thrown away.

This is kind of counter-intuitive, and I don't think there is a workaround for it.
IMHO, Tx.CheckReloadFiles() should not overwrite the entire global dictionary.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.