🚀 Welcome to MDriven Learn –  Don’t miss the latest Release Notes.
Localization

If your MDriven system discovers the pattern from the above model, you may install the IMDrivenUITranslation service. The MDriven system will use the data found in the objects for the model and use them as translations.

The service is installed like this:

MDriven.Translation.MDrivenUITranslationImpl.Install(ecoServiceProvider);// Installs translation services

Newer versions of MDriven Turnkey already do this for you.

The IMDrivenUITranslation has a Default-Language setting. The Default Language is set by MDriven Turnkey to the Language set in the user's browser. Typically, this is a value like “en-US” or “sv-SE”. You can force the default language with an action like this:  'Whatever'.Translate('DEFAULT=sv-SE');

To translate to the user's chosen language, do this:

'Translate this text'.Translate('') 

‘Translate this’.Translate(‘sv-SE’) is a valid expression that will try to look up a SysTranslatable object with a Value equal to ‘Translate this’. It will then look for Translations that point to a Language with code that equals ‘sv-SE’. If found, the value of the matching SysTranslation object will be returned. If no matching translation is discovered, the original value is kept.

It would be a complete pain to create all the SysTranslatables by hand. To help you avoid that, you can perform this in an action: 'Whatever'.Translate('SPOOLMISSED'). Sending “SPOOLMISSED” as a language has a special meaning and creates SysTranslatables for all complete misses that the system has seen since the start or since the last call to SPOOLMISSED.

The actual dictionaries used to do the translations are created at the system start-up. This means that you will need to restart your system to see the newly added translations take effect. This may not be a possibility, however, for the translators on your team. Most likely, the translators are just ordinary users or administrators of your system, but they will want to see the effect of an added translation as soon as possible. To mitigate this, we have added yet another special meaning language identifier: 'Whatever'.Translate('RESETCACHE'). This will reset all cached pages in your application since they possibly contain translations – and by the time of the next request, they will be redone and thus reflect the newly made translations.

The article introducing this functionality can be found here: https://blog.mdriven.net/localization/

Updates 2025-09-03: Metric Imperial and default decimal-number string format

Read about MetricImperial conversions here Documentation:MetricImperial - MDrivenWiki

Error creating thumbnail: File missing

The pattern has been extended with the SysCultureSettingsSingleton that lets you (probably your user) control 2 different settings for culture rather than the 1 default provided by the browser.

Culture controls what we give to the browser and will affect how numbers and dates are rendered (thousand separator, a comma or point, etc.) - and TranslationCulture controls the current SysTranslationLanguage.

The SysCultureSettingsSingleton properties can easily be made derived and you can let your user own their own values.

The DefaultDecimalDisplay setting will inject a StringFormat for Angular/Blazor/WPF if none is present already and it will use a pattern like "0.00<zeros controlled by DefaultDecimalDisplay>#######". This setting is aimed at getting a consistent display of decimal numbers with no effort.

As a generic rule, the DefaultDecimalDisplay will be multiplied by 2 on attributes if the MetricImperial functionality indicates Imperial (this is to manage the higher precision needed on all Imperial numbers due to their less granularity).

Updates 2020-09-23: Language Mapping Override

Add a static method on SysTranslateLanguage with this signature:

CheckLanguageMapping(input:String):String

This method is called when the user's language is detected. You may replace the user's language with some other language in order to implement preferred user language mapping.

Maybe you designed it in Swedish and you have added translations for English, but you get a French user and want to show English rather than Swedish:

if input.contains('fr') then
  'en'
else
  input
endif