translation resource directionary
Posted: 09 Nov 2020, 11:37
How would you suggest handling translations. It seems the recommended way is a resource dictionary and something like
Now this works well enough for all static text but a lot of text in a game is dynamically supplied via binding. It seems to be impossible to trigger resource lookups via binding. So this leads to having two sperate translation tables in two places. Not an optimal solution. Is there anything that would support a better solution.
Kind of in the same category is my other problem, giving a button a custom color via binding. Something I haven't been able to figure out. Of course it is possible to work with triggers. On a table that can have 4 colors I can work with something like this
But imagine this table
Every column is supposed to have their own color and the buttons are toggleable. That would create about 50-60 triggers per button for a few hundred buttons. I don't believe that is feasible. Since those buttons already have their own classes and bindings in the model the easiest way would be to provide a color binding but that doesn't seem to exist in XAML.
Code: Select all
<TextBlock Text="{StaticResource prefix-key}"></TextBlock>
Kind of in the same category is my other problem, giving a button a custom color via binding. Something I haven't been able to figure out. Of course it is possible to work with triggers. On a table that can have 4 colors I can work with something like this
Code: Select all
<Style.Triggers>
<DataTrigger Binding="{Binding Activity}" Value="N">
<Setter Property="Background" Value="{StaticResource ActivityNoneBrush}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Activity}" Value="E">
<Setter Property="Background" Value="{StaticResource ActivityEatBrush}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Activity}" Value="S">
<Setter Property="Background" Value="{StaticResource ActivitySleepBrush}"/>
</DataTrigger>
<DataTrigger Binding="{Binding Activity}" Value="T">
<Setter Property="Background" Value="{StaticResource ActivityTrainBrush}"/>
</DataTrigger>
</Style.Triggers>
Every column is supposed to have their own color and the buttons are toggleable. That would create about 50-60 triggers per button for a few hundred buttons. I don't believe that is feasible. Since those buttons already have their own classes and bindings in the model the easiest way would be to provide a color binding but that doesn't seem to exist in XAML.