There are different options that are available for you as a Mashup developer. You can create resource files relative to the mashup project, or you can use M3 constants or you can reuse constants available in Lawson Smart Office.
To add language files to the project do the following. Create a folder named “Localization” and in that folder you create one xml file per language that you would like to support. The xml file should be named to the language code. Start by adding en-us.xml. You add it to the Mashup project by selecting “Add resource” and point to the en-us.xml file.
The xml content should look similar to this:
<?xml version="1.0" encoding="utf-8" ?> <assembly name="CurrencyConverter"> <area name="Convert Tab"> <entry name="Convert" type="Header" comment="">Convert</entry> <entry name="About" type="Menu" comment="">About...</entry> <entry name="Refresh" type="Menu" comment="">Refresh</entry> </area> <area name="Rates Tab"> <entry name="Rates" type="Header" comment="">Rates</entry> <entry name="ConvertAmount" type="Label" comment="">Convert this amount:</entry> </area> </assembly>
There can be many areas but the name still has to be unique in the file since the name is what will be used as a key.
Lawson Smart Office currently supports the following languages: cs, da, de, el, en-US, es, fi, fr, hu, it, ja, nl, no, pl, pt, ru, sv, zh-CN.
To use the constants use the markup extension Constant. The mashup namespace is already declared so the value for the Content (or Text, Heading depending on control) is what you need to add.
<Label Content="{mashup:Constant CurrencyWidgetDescription}" />
You can read more about the Constant Extension in the Mashup SDK documentation found in the Designer.
Once the above steps are completed your mashup project will look like this:
Lawson Smart Office uses similar XML resource files for it’s constants. They are divided into one resource file per assembly. Each file corresponds to a generated language file with static fields. You can use these constants as well. The constants that are available are documented in the LSOSDK.chm which is delivered in the SDK pack (not the documentation that is in the mashup designer). The documentation that is in the mashup designer is MashupSDK.chm and this file is also available in the SDK pack.
For the Mango.UI assembly the language class is named LangUI.
For Mango.Core the language name is LangCore. For MForms the language class is Lang in the MForms namespace. Use the SDK documentation to browse and search for available constants. You use the constant as you would use any static reference in xaml.
<Label Content="{x:Static lang:LangUI.Related}" />
NOTE! In the example above you need to declare the “lang” namespace to your Mashup Grid.
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:lang="clr-namespace:Mango.UI;assembly=Mango.UI" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI"> </Grid>
A third alternative would be to use language constants for M3. Language constants are available in MVXCON or in MVXMSG, in order to know which constants are avalailable you need to use the MAK tools for M3. For MIDetail panenels we have the option of generating the mashup with these constants. You need to know the name of the constant and which file it belongs to. The syntax is as follows:
<Label Content="{m3:Constant Key=WCU0215,File=MVXCON}" />
The M3 markup extention will use the M3 language from MNS150.
The complete example is available here.
Some final notes:
You need to restart LSO if you change language files becuase they are cached.
The language culture name is taken internally from the LSO (client) language, NOT the language of the M3 User.
Hi.
I have used quite some time getting this feature to work before I read the final note.
So to all others outthere in MashUp country. Remember to restart LSO 😉
Hello,
I have a problem when I want to translate in Chinese your mashup. I create a new file “cs.xml” in “Localization” folder. And I add it in the resources.
When I open the mashup in the designer, I have got the message “. It look likes the file do not exist and not add in the resources.
Can you help me please ?
Regards
Hello
I found the problem, it is the name of the file.
For chinese the file name is “zh-CN.xml”
Regards
Hello
We currently use this method for our mashups. Is it possible to define a default language file ?
Best regards
Christian
The English file is the default language file. I don’t think you can define another default language. But I’m going to check. Sorry for the late reply.
Hi,
Could you find anything regarding the default language?
The thing is that you would need a translation file for each and every language setting that is used in Smart Office. However, for the majority of users, English texts would be ok (even if they have Smart Office language “de” for example).
So I was wondering if there is a fallback xml file or so.
best regards,
Mario
Hi,
It’s been a while since I used localizations in Mashups but it should default to English. If it does not use a file as default then you should report that to support. We continue to add new languages all of the time and there is no way we can expect Mashup developers to translate to all languages.
I did send a reminder to the Mashup framework developer. Let’s hope he replies before I forget again 🙂