PDA

View Full Version : Plugins' strings



mherger
2005-02-14, 00:28
Two problems with the plugins' strings:

- I've mentioned first one before: the strings aren't recognised as utf8.
I tried my luck with utf8::upgrade - did not work.

- The second is related to some changes Dan did recently. He replaced the
following:

sub strings { "
PLUGIN_SOME_STRING
DE Irgendwas
EN Some String
";}


....by the following construction I don't understand :-):

sub strings {
local $/ = undef;
<DATA>;
}

__DATA__
PLUGIN_SOME_STRING
DE Irgendwas
EN Some String


This seems to be working _only_ when the plugin is checked/read for the
first time. In my StringEditor plugin I'm using the following to re-read
all strings:

sub initStrings {
Slim::Utils::Strings::init();
Slim::Buttons::Plugins::read_plugins();
}

This fails for the plugin with the afore mentioned strings() method, all
others are fine. Any idea?

--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the
SlimString Translation Helper (http://www.herger.net/slim/)

mherger
2005-02-14, 02:43
> - I've mentioned first one before: the strings aren't recognised as
> utf8. I tried my luck with utf8::upgrade - did not work.

The following seems to do the trick:

$string = pack "U0C*", unpack "C*", $string;

Find attached a patch for Slim::Buttons::Plugins which does this when
reading strings.

--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the
SlimString Translation Helper (http://www.herger.net/slim/)

mherger
2005-02-16, 02:23
Dan,

[..]
> ...by the following construction I don't understand :-):

By now I do understand it :-).

> sub strings {
> local $/ = undef;
> <DATA>;
> }
[..]
> This seems to be working _only_ when the plugin is checked/read for the
> first time. In my StringEditor plugin I'm using the following to re-read
> all strings:

DATA is a file handle and would have to be rewinded. But this will rewind
all the file and not only the DATA part. Any idea how to solve this? I've
found some solutions working with an $offset variable, but this
complicates things.

BTW: rather a pure perl question than slimserver related... what's the
advantage of this method compared to a simple

sub strings { return '
EN My new string
'};

? I see that the strings sub is much smaller and clear. But beside this,
is there an advantage in performance or memory usage?

--

Michael

-----------------------------------------------------------
Help translate SlimServer by using the
SlimString Translation Helper (http://www.herger.net/slim/)