This repository has been archived by the owner on Aug 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Translations
Dr.Hacknik edited this page Apr 26, 2016
·
4 revisions
Because the INI file format is robust, and easy to edit and understand, it was used in the translation engine.
This example proves my point:
[_meta]
language=English
translator=MarcusD
[FirstTimeWizard]
title=3DNUS - First time setup Wizard
[EulaDialog]
title=License agreements
accept=I accept the license requirements
decline=I decline the license requirements
next=Next
[Main]
download=Download
mode_legacy=Legacy mode
There's the _3DNUS.i18n
namespace that provides 2 classes: Localizer
and LocalizedForm
.
You can very easily translate your Form, if you're using LocalizedForm, just follow the below steps:
- Import the
_3DNUS.i18n
namespace - Make sure your Form extends LocalizedForm (change
: Form
to: LocalizedForm
- Override the
TranslationTrigger
function - In the overridden function,
yield return
the controls you want to translate - Set the
Tag
property of the controls to a String, which will be later used to identify the translation in the language file - Set the
Tag
property of the Form to a String, which will be used as the section name identifier in the language file - Place the translation files in the
<source>/i18n
folder, and set the build action toEmbedded resource
Example:
using _3DNUS.i18n;
public class FormDemo : LocalizedForm
{
public FormDemo() : base()
{
InitializeComponent();
this.Tag = "DemoDialog";
Label1.Tag = "info";
ButtonRetranslate.Tag = "retranslate";
}
public override IEnumerable<Control> TranslationTrigger()
{
yield return Label1;
yield return ButtonRetranslate;
}
protected void ButtonRetranslate_Click(object sender, EventArgs e)
{
Localizer.PleaseTrigger(this);
}
}
[DemoDialog]
info=Click the below button to retranslate this form:
retranslate=Click me to retranslate this window!
© 2014-2018 Ground, Dr.Hacknik, and MarcusD.
Welcome to the Wiki for 3DNUS. Currently, the Wiki is still being worked on! Soon though, it'll be completed!