Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to refactor a Symbol in Dolphin

4 views
Skip to first unread message

Christoph J. Bachinger

unread,
Dec 12, 2009, 5:35:49 AM12/12/09
to
In my application I'm using Symbols as placeholders for Strings to
provide multi language support. To refactor the symbol names I wouuld
like to click on my Symbol in the MethodWorkspace and start refactoring
with an hit on F2. But the refactor dialog shows the active method name
and not the symbol.

Is there an other way to refactor symbols.

At the moment I have to define a method with the same name as my Symbol
saving it. Refactor the symbol method and deleting the method. Most
times I like to refactor a bunch of symbols. So this way is very
unconvinient.

Any suggestions appriciated.

thanks
cjb

GallegO

unread,
Dec 12, 2009, 9:20:35 AM12/12/09
to
Hi!

Maybe you should use PoolDictionaries (and write keys) instead of
symbols. I don't say that PoolDictionaries are the best solution but
are comparable with your current implementation.

Another solution we have implemented is using Strings, but no as
placeholders. String was extended with #translated implementing the
translation logic for the current language of the user.
i.e.

'Helo' translated -> If the user has english as language, #translated
answers 'Hello', but 'Hola' if the user is in spanish.
'I'm <1d> years old' translated expandMacrosWith: 20 (on my dreams) ->
'Tengo 20 años' if the user is in spanish

All the translations are mantained in a LookupTable that can be
exported in xml.

Additionally we mark all the translatable strings with the character @
as the first character so find all translatable strings
is as easy as "String allInstances select: [:each | each firstOrNil ==
$@]".
Using this technique you should remove @ as the first character in the
#translate implementation of String (If you mask @ with @ i.e.
'@@domain' you ends with '@domain' so there are no problems).

Cheers
Sebastian Calvo

On 12 dic, 07:35, "Christoph J. Bachinger" <bachinger.softw...@t-

John Brant

unread,
Dec 12, 2009, 10:11:16 AM12/12/09
to Christoph J. Bachinger

You can use the Code Rewriter if you want to rename the symbols. For
example, to rename #foo to #bar: select your packages, switch to the
code rewriter, enter #foo at the top, #bar at the bottom, and hit the
Replace button. This will open another window with all of the potential
changes that you can accept or reject.


John Brant

Christoph J. Bachinger

unread,
Dec 13, 2009, 11:49:34 AM12/13/09
to
Hi John,

How to select the packages or only one Package. Normaly im using the
Sytembrowser to code for my application. So my Package is already
selected. If I switch to the Code Rewriter I can change the #foo to #bar
and hit the Replace button. But the change is only in this method and
not in the Package or Class.

cjb

John Brant schrieb:

Christoph J. Bachinger

unread,
Dec 13, 2009, 11:58:58 AM12/13/09
to
Hi GallegO

> Maybe you should use PoolDictionaries (and write keys) instead of
> symbols. I don't say that PoolDictionaries are the best solution but
> are comparable with your current implementation.

The symbols are the keys in the dictionary of the langugage instance.

>
> Another solution we have implemented is using Strings, but no as
> placeholders. String was extended with #translated implementing the
> translation logic for the current language of the user.
> i.e.
>
> 'Helo' translated -> If the user has english as language, #translated
> answers 'Hello', but 'Hola' if the user is in spanish.
> 'I'm <1d> years old' translated expandMacrosWith: 20 (on my dreams) ->

> 'Tengo 20 a�os' if the user is in spanish


>
> All the translations are mantained in a LookupTable that can be
> exported in xml.
>
> Additionally we mark all the translatable strings with the character @
> as the first character so find all translatable strings
> is as easy as "String allInstances select: [:each | each firstOrNil ==
> $@]".
> Using this technique you should remove @ as the first character in the
> #translate implementation of String (If you mask @ with @ i.e.
> '@@domain' you ends with '@domain' so there are no problems).

The idea is not bad. But I don't like to change the horse at the end of
a development.

Thanks
cbj

John Brant

unread,
Dec 14, 2009, 8:16:35 AM12/14/09
to
Christoph J. Bachinger wrote:

> How to select the packages or only one Package. Normaly im using the
> Sytembrowser to code for my application. So my Package is already
> selected. If I switch to the Code Rewriter I can change the #foo to #bar
> and hit the Replace button. But the change is only in this method and
> not in the Package or Class.

You'll need to deselect your class/method. Otherwise, it will run on
only the class/method that you have selected.


John Brant

Christoph J. Bachinger

unread,
Dec 14, 2009, 1:18:23 PM12/14/09
to
John Brant schrieb:

Sorry to be so annoying to you, but I see only one method in the list
while if I do a shift F12 I see much more senders of my Symbol but this
is in a Methodbrowser and not in the code rewriter methodlist.

Deselection the only message highlights all menu entries without "Accept
all changes". Selecting it does only a change in the one method listed.

cjb

0 new messages