Author Topic: obmenu-generator in various languages [Solved]  (Read 628 times)

Offline kendew

  • Newbie
  • *
  • Posts: 17
obmenu-generator in various languages [Solved]
« on: August 28, 2017, 02:42:12 am »
Hi
I've always liked obmenu-generator and I'm grateful to Sparky for keeping this alive.  But is it possible to get it to display in languages other than English?  I'm interested in Japanese specifically but there must be other people using obmenu-generator in non-English languages whatever they might be.  I started the OS install from the start in Japanese and also added it as an environmental variable in Openbox  as
Code: [Select]
LANG=ja_JP.UTF8 which helps with Openbox, but I'm not sure where to put the language encoding or how for obmenu-generator.
Help appreciated
Kendew
« Last Edit: September 20, 2017, 03:43:02 am by kendew »

Offline pavroo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1702
    • SparkyLinux
Re: obmenu-generator in various languages
« Reply #1 on: August 28, 2017, 01:06:50 pm »
Hi
Somebody asked me already about the same, but with Polish lang.
I will try to create separate locale files (en and pl on the beginning) and if works fine, can be translated to other languages.
« Last Edit: August 28, 2017, 01:08:41 pm by pavroo »
Nothing is easy as it looks.
Danielle Steel

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #2 on: August 28, 2017, 08:04:08 pm »
Yes!  I would like to see those files and see what I could do with Japanese.  But since obmenu-generator has I think been around for awhile, wouldn't the files be around somewhere, maybe in at least one other locale?

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #3 on: August 30, 2017, 02:26:39 am »
OK.  Let's say for the time being obmenu-generator is going to stay in just English.  I'm using tint2 with OpenBox and I wonder if within tint2 it's possible to put an app that would display an application menu (a dynamic one), that is an icon where when you clicked on it the menu would display in the targeted language?  An alternative until we can figure out how obmenu-generator can handle different locales?

Offline pavroo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1702
    • SparkyLinux
Re: obmenu-generator in various languages
« Reply #4 on: August 30, 2017, 12:49:56 pm »
A different locales can be configured via:
Code: [Select]
~HOME/.config/obmenu-generator/config.plchange:
Code: [Select]
"name_keys"           => ["Name"],to your lang, for example pl_PL:
Code: [Select]
"name_keys"           => ['Name[pl]', 'GenericName[pl]', 'Name'],
Missing lang is about the category names and custom entries only.
Nothing is easy as it looks.
Danielle Steel

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #5 on: August 31, 2017, 06:10:15 am »
Just curious if you actually tried this and got it working?   I couldn't with Japanese, but Japanese, being a two-byte language, has certain difficulties.  I am going to research this further and report back.  Please do also.
Kendew

Offline pavroo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1702
    • SparkyLinux
Re: obmenu-generator in various languages
« Reply #6 on: August 31, 2017, 09:18:01 pm »
Yes I did, It works fine in Polish.
I tried with jp, but it displays in English.
Maybe the app developer doesn't add support for jp locale yet?
Nothing is easy as it looks.
Danielle Steel

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #7 on: September 01, 2017, 01:21:28 am »
Just checking, and I don't want to be wasting your time, but you did use pl in the line
Code: [Select]
"name_keys"           => ['Name[pl]', 'GenericName[pl]', 'Name'],and not something like pl_PL or pl_PL.UTF-8?   I wonder where pl gets defined?  Somewhere in the code must point to the locale and I don't imagine the app developer creates files with the name of every possible program in the Polish language but must use names already there, somewhere?
Hope we can get to the bottom of this, and thanks for your help.
Kendew

Offline pavroo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1702
    • SparkyLinux
Re: obmenu-generator in various languages
« Reply #8 on: September 01, 2017, 01:30:24 am »
I am not sure, but I think that the tool reads Name and GenericName locale from .desktop files, that's why it displays names in local language if possible. If not it uses English names, but don't know why it doesn't want to use jp.
Nothing is easy as it looks.
Danielle Steel

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #9 on: September 01, 2017, 03:29:02 am »
Got it!!
Had to go looking at Japanese manuals, but what needs to be done is the locale has to be activated.  This requires editing /etc/locale.gen with sudo privileges and un-commenting any locale you need active, in my case it was  ja_JP.EUC-JP EUC-JP and ja_JP.UTF-8 UTF-8.  After that locale-gen must be run from the terminal with root privileges and the system rebooted. 
Once this was done, obmenu-generator had a lot of Japanese entries.  Not all words were Japanese, perhaps because the software doesn't have equivalents for some of them yet. 
But it's a start.  I'm going to investigate further and report back what I find.  For some reason, pavroo, the Polish locale was already active, but this should help anyone who needs a special language.  I could just substitute ja where you put pl. 

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #10 on: September 02, 2017, 02:31:14 am »
Going further with this -- taking it back to applications that don't have a designated name in another language.  For example the graphic image viewer called Mirage.  If we look at the file in /usr/share/applications I see only an English name.  However, if I add ' Name[ja]= ' under the Name= entry, I can change it to anything I want and it will appear as such in obmenu-generator, because I have set obmenu-generator to use ja and activated the ja locale, as already mentioned.  Now, it's possible to get quite creative here.
But there is a problem:  these files could get over-written.   Also, they might be suitable for everyone logged in to the system.   So I am trying to figure out a way to create files that will not be overwritten by an obmenu-generator upgrade and localized.  I've tried created them in ~.local/share/applications with owner and group set to that particular user (instead of root) but so far this hasn't been successful. 
Do I have the directory wrong?  Any ideas how to do this?
Already tried
Code: [Select]
sudo update-desktop-database ~/.local/share/applications
Kendew
« Last Edit: September 02, 2017, 02:56:24 am by kendew »

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #11 on: September 02, 2017, 11:49:01 pm »
Well, I may have come to the end of the road.  I don't know.  I looked carefully at the file config.pl.  I noticed there is a line:
Code: [Select]
  "Linux::DesktopFiles" => {
                             desktop_files_paths     => [
        "/usr/share/applications",
                                                          "/usr/local/share/applications",
                                                          "/usr/share/applications/kde4",                               
                                                        ],
This is telling obmenu-generator where to look for desktop files and explains why my changes to desktop files in ~/.local/share/applications were not showing up.  Adding
Code: [Select]
~/.local/share/applications to this line did indeed get the changes showing, but everything was in duplicate!! as obmenu-generator took the entries from both places!
Now looking at config.pl it seems there may be a way to get obmenu-generator to skip files with the same name, but I haven't looked into it yet because I saw these other lines at the top of the file:
Code: [Select]
# obmenu-generator - configuration file
# This file will be updated automatically.
# Any additional comment and/or indentation will be lost.
If this is so, it means any changes I make will be deleted??? 
If so, I'm not where to proceed from here except explore other dynamic menu systems.  Kind of liked obmenu-generator though.
Kendew

Offline pavroo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1702
    • SparkyLinux
Re: obmenu-generator in various languages
« Reply #12 on: September 03, 2017, 12:38:54 pm »
What version of obmenu-generator you have installed?
The latest one supports all locations:
Quote
"/usr/share/applications",
"/usr/local/share/applications",
"/usr/share/applications/kde4",
"$ENV{HOME}/.local/share/applications",
Nothing is easy as it looks.
Danielle Steel

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #13 on: September 05, 2017, 04:48:46 am »
0.80~sparky20170824.
But that was not my worry.  Sorry if I didn't explain well.  Bear with me ~ The problem with obmenu-generator is for various reasons. 
1.  I don't want to edit files in /usr/share/applications.  This is generally recommended from what info I can gather, but at the very least these files could get overwritten. 
Let's take an example using the image-viewer app called Mirage, which has no Japanese equivalent.  If I add a Japanese equivalent using
Code: [Select]
Name[ja]=, it works fine, but a future version of Mirage could easily overwrite the file and my changes will be lost. 
Generally, it's recommended to use
Code: [Select]
$ENV{HOME}/.local/share/applications".  In this way, future upgrades will not overwrite my changes.  To do this, however, I have to edit the obmenu-generator file to include $ENV{HOME}/.local/share/applications, as in
Code: [Select]
  "Linux::DesktopFiles" => {
                             desktop_files_paths     => [
        "/usr/share/applications",
                                                          "/usr/local/share/applications",
                                                          "/usr/share/applications/kde4",
                                                          "$ENV{HOME}/.local/share/applications",                               
                                                        ],
However, if I do so, and a mirage.desktop file is also in /usr/share/applications as well as ~/.local/share/applications, the entry Mirage appears twice in the Graphics section of the menu.

Now, reading config.pl there is an entry skip_entry  which may offer a way to skip the /usr/share/applications if also in /.local/share/applications. 
If you know how to use this, please teach me.
2.  The top three lines of config.pl state
Code: [Select]
# obmenu-generator - configuration file
# This file will be updated automatically.
# Any additional comment and/or indentation will be lost.
So it sounds like, even if I figure out a way to make it all work, some future update of obmenu-generator could wipe out all my changes anyway.
Let me know if I'm wrong here.
I really like obmenu-generator, but if I can't get around these problems, I think I have to look into another solution.

Offline kendew

  • Newbie
  • *
  • Posts: 17
Re: obmenu-generator in various languages
« Reply #14 on: September 20, 2017, 03:42:04 am »
Well, today there was an obmenu-generator upgrade.  My fears were proven well founded as obmenu-generator very aggressively overwrote files, even in the user home directory, and even the menu.xml file in the Openbox directory was overwritten, which surprised me as this file was not originally created by obmenu-generator. 
My conclusion is obmenu-generator is really great for what it does but has its limitations.  In particular, it's hard to make adjustments as they will get overwritten. 
One solution, I suppose, might be not to install obmenu-generator from a repository, but my solution is to create my own pipemenus, a solution openbox easily allows.  To do this I see it is necessary to uninstall obmenu-generator so openbox's menu.xml file doesn't get overwritten.