ygoe / TxTranslation

Tx Translation & Localisation for .NET and WPF
GNU General Public License v3.0
28 stars 12 forks source link

Design time text is blank #11

Open JoshWobbles opened 7 years ago

JoshWobbles commented 7 years ago

Shouldent design time show the default text, or at least the key?

vlkam commented 7 years ago

Yes, the default text or the key should be shown Unfortunately (I do not know why) the Tx does not show actual data. It's only one issue to the Tx

ygoe commented 7 years ago

There is no dictionary available at design time because it's loaded through runtime code. I have thought about supporting this somehow but couldn't find a solution. After all, you could even build up the dictionary content through code and not use a .txd file at all.

So there are only two possibilities what can happen at design time:

  1. The text key is displayed. This is the default if nothing else is specified.
  2. A default text is displayed. This must be specified in the XAML file, and yes, it may become obsolete and misleading when the actual text in the dictionary changes. You can select the option to include the default text when using the wizard from TxEditor. In this case, the literal text that was in the XAML file before will be added as default text. This should only be used at design time, I'd have to look it up.
JoshWobbles commented 7 years ago

How do I set the default text? English is green but at design time all my text just shows the key names.

ygoe commented 7 years ago

Just look around in the TxEditor source code, it's full of it. TxEditor is a good reference on how to use the TxTranslation library in general.

vlkam commented 7 years ago

I do not know, how it works in WPF designer, but for Xamarin Forms Previewer I've made changes in TxLib and it shows actual data from txd file. I think it would work for WPF designer. Also I've ported TxLib into PCL. This fork works but it's very raw unfortunately.

I'd like to say thank you very much for the great TxTranslation, best ever system for string resources managing!

Today I've finished to work on fork of the TxEditor for export into Android resources and CSharp code files.Next is export to iOs resource files. I'm totally amazed capability and potential of TxTranslation! The code inside is very elegant and clear. When I've finish this solution I'd like to offer pull request to TxLib

I've have only one question why so few people use this amazing and no doubt uniqe library

ygoe commented 7 years ago

I have no experience with Xamarin.Forms yet, but it's right next on my list. Could you show me how the dictionary text is displayed at design time there?

I also intend to add .NET Standard support to TxLib, for one of my projects, but there's no definitive time frame yet. Should be still in 2017.

vlkam commented 7 years ago

I load a txd file from embedded resources in the constructor of main App class.

        Stream stream = Auxiliary.ResourceLoader.GetStream("Resources.Dictionary.txd");
        //Tx.SetCulture("ru-RU");
        Tx.SetCulture("en-US");
        Tx.LoadFromStream(stream);

and make bingings image

This works only for current alfa version of Xamarin Form Previewer. And I've slightly changed the TxLib Here is a small demo https://github.com/vlkam/HardwareStore

I think this approach would be work for WPF designer because it also executes main App class in process of working

If you have any questions I'm happy to answer.

Once again, thanks a lot for really stunning library and awesome TxEditor!