Bug 8752 - Add "getstring" CLI command
: Add "getstring" CLI command
Status: CLOSED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: CLI
: unspecified
: PC Other
: P3 enhancement (vote)
: 7.x
Assigned To: Michael Herger
: ipeng
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-15 23:39 UTC by Joerg Schwieder
Modified: 2009-09-08 09:12 UTC (History)
0 users

See Also:
Category: ---


Attachments
"getstring" CLI command (2.20 KB, patch)
2008-07-21 06:22 UTC, Michael Herger
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joerg Schwieder 2008-07-15 23:39:50 UTC
I would like to see a "translate" CLI command that takes string code (as from strings.txt) as an input and returns the localized string.

This would greatly enhance the capability to build interfaces from JavaScript or native interfaces since you don't have to go through TT and pre-store values and you don't have to know upfront what your string codes would be.

One example: in iPeng I have a scanner page that shows progress on the database scan. I have to pre-store all "XXX_PROGRESS" values there even though XXX is something returned by the CLI so with this command I could just construct the XXX_PROGRESS identifier and get the string value.

This would be useful for any 3rd party controller app plus for the Default skin and Jive I suppose.
Comment 1 Michael Herger 2008-07-16 01:04:37 UTC
Ah... forgot to submit this request myself. Could come in handy in some web skins, too.

Let's discuss some more ideas: what about a "batch" mode, where you can get several translations at once? eg.

getstring BRIGHTNESS
getstring BRIGHTNESS:Helligkeit
getstring HOME,INFORMATION,EDIT
getstring HOME:Hauptmenü,INFORMATION:Information,EDIT:Bearbeiten

Hmm... I'll have to check the CLI specs to see how this could best be done.
Comment 2 Michael Herger 2008-07-16 01:06:02 UTC
changing summary to better fit the internal command
Comment 3 Michael Herger 2008-07-21 06:22:20 UTC
Created attachment 3635 [details]
"getstring" CLI command

getstring HOME,PLUGIN_RANDOMPLAY,SOME_TOKEN

Please give it a try and let me know whether this does what you're looking for.
Comment 4 Joerg Schwieder 2008-07-21 06:31:22 UTC
Can I apply this to a "build" version of the server or do I have to use a SVN version? If it's the latter I'll try tomorrow.
But looks good and I like the "batch" mode.
How are the results encoded? Just asking because of Erland's "%"-issue.
Comment 5 Michael Herger 2008-07-21 06:54:41 UTC
If you have a patch tool you can apply it to any version. Otherwise it's simple enough to just copy the content into the corresponding files. Just remove the leading + signs.
Comment 6 Joerg Schwieder 2008-07-21 15:58:42 UTC
OK, tried it, and it's about what I'm looking for.
If it can translate, it translates -> good
If it cannot, it returns the tag -> good
It returns the result in a hash -> good
It works with plugins -> good

But the "batch mode" doesn't seem to work, at least with JSON/RPC. I can hand over several parameter but only the first one gets returned. -> bad.

I'll add a bit of logging.

[08-07-22 00:56:55.1396] Slim::Web::JSONRPC::handleURI (73) handleURI(Slim::Web::HTTP::ClientConn=GLOB(0x68faef4))
[08-07-22 00:56:55.1400] Slim::Web::JSONRPC::handleURI (108) POST data: [{"id": 1, "method": "slim.request", "params": ["01:01:01:01:01:01", ["getstring", "MUSICIP_PROGRESS", "IPENG_WEEKDAY_SEL", "MUSTBEINVALID", "SLEEPING_IN_X_MINUTES"]]}]
[08-07-22 00:56:55.1449] Slim::Web::JSONRPC::handleURI (126) JSON parsed procedure: {
  id => 1,
  method => "slim.request",
  params => [
        "01:01:01:01:01:01",
        [
          "getstring",
          "MUSICIP_PROGRESS",
          "IPENG_WEEKDAY_SEL",
          "MUSTBEINVALID",
          "SLEEPING_IN_X_MINUTES",
        ],
      ],
}
[08-07-22 00:56:55.1457] Slim::Web::JSONRPC::requestMethod (308) requestMethod([
  "01:01:01:01:01:01",
  [
    "getstring",
    "MUSICIP_PROGRESS",
    "IPENG_WEEKDAY_SEL",
    "MUSTBEINVALID",
    "SLEEPING_IN_X_MINUTES",
  ],
])
[08-07-22 00:56:55.1478] Slim::Web::JSONRPC::requestMethod (330) Parsing command: Found client [01:01:01:01:01:01]
[08-07-22 00:56:55.1523] Slim::Web::JSONRPC::requestMethod (352) Dispatching...
[08-07-22 00:56:55.1528] Slim::Web::JSONRPC::requestWrite (398) requestWrite()
[08-07-22 00:56:55.1531] Slim::Web::JSONRPC::generateJSONResponse (278) generateJSONResponse()
[08-07-22 00:56:55.1542] Slim::Web::JSONRPC::writeResponse (224) JSON response: {
  id => 1,
  method => "slim.request",
  params => [
        "01:01:01:01:01:01",
        [
          "getstring",
          "MUSICIP_PROGRESS",
          "IPENG_WEEKDAY_SEL",
          "MUSTBEINVALID",
          "SLEEPING_IN_X_MINUTES",
        ],
      ],
  result => {
        # tied Tie::IxHash
        MUSICIP_PROGRESS => "MusicIP Import",
      },
}
[08-07-22 00:56:55.1545] Slim::Web::JSONRPC::writeResponse (237) JSON raw response: [{"params":["01:01:01:01:01:01",["getstring","MUSICIP_PROGRESS","IPENG_WEEKDAY_SEL","MUSTBEINVALID","SLEEPING_IN_X_MINUTES"]],"method":"slim.request","id":"1","result":{"MUSICIP_PROGRESS":"MusicIP Import"}}]
Comment 7 Michael Herger 2008-07-21 16:28:04 UTC
you'll have to send the tokens as one string. Probably a bit confusing...
[
          "getstring",
          "MUSICIP_PROGRESS,IPENG_WEEKDAY_SEL,SLEEPING_IN_X_MINUTES",
        ],
Comment 8 Joerg Schwieder 2008-07-21 22:55:32 UTC
OK, works fine then.

Wouldn't it be simpler to use separate parameters? I mean: from an application point of view: I don't really care if I have to concatenate strings or arrays but all the other CLI commands use separate parameters. Or would that become to many of those? The return hashes separate them, too, in the end (which is the important point)
Comment 9 Michael Herger 2008-07-21 23:24:24 UTC
Thanks for the feedback.

The current implementation imho is very simple and easy, not only to do the queries manually, but programmatically too. JSON responses result in a hash indexed by the tags. I don't see any advantage splitting the parameters into separate values, but clearly it would be more complicated to use.
Comment 10 Michael Herger 2008-07-22 05:59:42 UTC
change 21980
Comment 11 Spies Steven 2008-08-29 15:34:12 UTC
Verified with SqueezeCenter Version: 7.2 - 22900
Comment 12 James Richardson 2008-12-15 12:34:17 UTC
This bug has been fixed in the 7.3.0 release version of SqueezeCenter!

Please download the new version from http://www.slimdevices.com/su_downloads.html if you haven't already.  

If you are still experiencing this problem, feel free to reopen the bug with your new comments and we'll have another look.
Comment 13 Chris Owens 2009-07-31 10:24:52 UTC
Reduce number of active targets for SC