Forum > macOS / Mac OS X

[SOLVED] How to use "Resourcestring" in objectivec1 and objectivec2 mode

(1/2) > >>

Hansaplast:
Getting my feet wet with localization, I found that the use of Resourcestring is not supported in objectivec1 or objectivec2 mode.
See also: Resource string documentation.

To confirm: Doing some tests, I see there are not a single is being added to the .po file, when enabling i18n, for any of my objectivec1 or objectivec2  units in my application. Regular units (mostly objfpc mode) however are included.

How does one use Resourcestrings for units that require objectivec1 or objectivec2 mode? (typically when a unit utilizes one or the other macOS framework)

Note: I'd like to keep those units "generic" so I can reuse them with other projects without any not-so-obvious constructs.

wp:
Just an idea: The {$mode} can be set per unit. Can't you move all resource strings to a separate unit in which you have {$mode objfp}? This way you could keep {$mode objectivec1/2} in all other units, but still have resource strings.

Thaddy:
That is indeed the case and the documentation implies it...(it does not say objectivec mode won't work globally with such a unit in objfpc/delphi mode)
Try it. It may or may not work, I do never use resourcestrings myself but rely on resource files.

Hansaplast:
Yeah, took me a while to figure out why it didn't work - the documentation is the only place where I found it.
I did add it to the "Step-by-step instructions for creating multi-language applications" (macOS section) so others would see it.

I just wanted to use po files so other can help translating, as their native language.
The "system" to do this is there, so I figured; better use it if I can (and find/fix bugs if I find those as well).

Seems a FPC limitation. Just wondering how others work around this issue without going bonkers on constructs to wok around this.

So in short: it does not work in objectivec1 and objectivec2 mode.
Tested it with a objfpc mode unit and an objectivec1 unit. The objectivec1 unit is simply being skipped. The objfpc unit works as expected.

Hansaplast:

--- Quote from: wp on April 15, 2025, 10:27:22 am ---Just an idea: The {$mode} can be set per unit. Can't you move all resource strings to a separate unit in which you have {$mode objfp}? This way you could keep {$mode objectivec1/2} in all other units, but still have resource strings.

--- End quote ---

Well, that could work, but I want to keep the unit more generic so I can use it wth other applications as well without having to figure out time and again how the work around works.
Even thought about making them a variable, set at initialization to the default values and have the main application override them with Resourcestring.
Of course then I ran into one of my applications that uses objectivec1 mode to begin with.

Navigation

[0] Message Index

[#] Next page

Go to full version