[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [e4-dev] localize buttons and text
|
Hi,
The process is like this (these are the manual steps you can let the IDE
extract the strings for you):
a) Create a "Messages.properties"-File in package "foo"
b) Create a Java-Class-File "Messages.java" in package "foo"
c) Create an entry like "MyPart_Label=Hello" in the Messages.properties
d) Create a field "String MyPart_Label" in your Messages.java
e) Add a dependency to "org.eclipse.e4.tools.services" to your
MANIFEST.MF
f) Modify your Part-Class from something like this:
-------8<-------
public class MyPart {
@Inject
public MyPart(Composite parent) {
// ...
title = new Label(parent, SWT.CENTER);
GridData titleLData = new GridData();
titleLData.heightHint = 69;
titleLData.grabExcessVerticalSpace = true;
titleLData.verticalAlignment = GridData.BEGINNING;
titleLData.grabExcessHorizontalSpace = true;
titleLData.horizontalAlignment = GridData.FILL;
title.setLayoutData(titleLData);
title.setText("Hello");
title.setData("org.eclipse.e4.ui.css.id", "SeparatorLabel");
}
}
-------8<-------
To something like this:
-------8<-------
public class MyPart {
@Inject
public MyPart(Composite comp, @Translation Messages messages) {
// ...
title = new Label(parent, SWT.CENTER);
GridData titleLData = new GridData();
titleLData.heightHint = 69;
titleLData.grabExcessVerticalSpace = true;
titleLData.verticalAlignment = GridData.BEGINNING;
titleLData.grabExcessHorizontalSpace = true;
titleLData.horizontalAlignment = GridData.FILL;
title.setLayoutData(titleLData);
title.setText(messages.MyPart_Label);
title.setData("org.eclipse.e4.ui.css.id", "SeparatorLabel");
}
}
-------8<-------
That's it. Don't forget to update your launch config and .product after
having added the new org.eclipse.e4.tools.services dependency
Tom
Am 09.06.11 20:06, schrieb Deidre Stankard:
> yes I do think I will do it the way you do your modeltooling but I am
> a little confused of how it is working.
> Say for example I have a label called like such:
> title = new Label(parent, SWT.CENTER);
> GridData titleLData = new GridData();
> titleLData.heightHint = 69;
> titleLData.grabExcessVerticalSpace = true;
> titleLData.verticalAlignment = GridData.BEGINNING;
> titleLData.grabExcessHorizontalSpace = true;
> titleLData.horizontalAlignment = GridData.FILL;
> title.setLayoutData(titleLData);
> title.setText("Hello");
> title.setData("org.eclipse.e4.ui.css.id", "SeparatorLabel");
>
> To be able to change the text within the label from Hello to say
> french. How can I call title in the .properties?
>
> Deirdre.
>
> On 6/8/11, Tom Schindl <tom.schindl@xxxxxxxxxxxxxxx> wrote:
>> There are 2 possibilties:
>> * doing it in the 3.x way using NLS-System
>> * doing it like my modeltooling does it
>>
>> -http://dev.eclipse.org/viewcvs/viewvc.cgi/e4/org.eclipse.e4.tools/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/ModelEditor.java?view=markup
>>
>> -http://dev.eclipse.org/viewcvs/viewvc.cgi/e4/org.eclipse.e4.tools/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.java?view=markup
>>
>> -http://dev.eclipse.org/viewcvs/viewvc.cgi/e4/org.eclipse.e4.tools/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/Messages.properties?view=markup
>>
>> I think my way of doing it is better because:
>> a) messages don't stay in memory for ever
>> b) it will support multiple locales at once and dynamic language
>> switching
>>
>> Tom
>>
>> Am 08.06.11 21:41, schrieb Deidre Stankard:
>>> Hi,
>>>
>>> I am undergoing localization in my project in eclipse 4.1 and I can
>>> localize trimmed windows and on my toolbar etc which are all done in the
>>> application.e4xmi using the '%' call in the label.
>>> I am just wondering can localization be used in eclipse 4.1 with names
>>> on my buttons and text within my GUI as these are called in my java
>>> files? and if so how?
>>>
>>> Regards,
>>> Deirdre.
>>>
>>>
>>>
>>> _______________________________________________
>>> e4-dev mailing list
>>> e4-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/e4-dev
>>
>> _______________________________________________
>> e4-dev mailing list
>> e4-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/e4-dev
>>
> _______________________________________________
> e4-dev mailing list
> e4-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/e4-dev