Welcome to SparkyLinux forums
Zapraszamy również na polsko-języczne Forum https://forum.linuxiarze.pl

obmenu-generator in various languages [Solved]

Started by kendew, August 28, 2017, 02:42:12 AM

Previous topic - Next topic

kendew

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 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

pavroo

#1
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.
Nothing is easy as it looks. Danielle Steel

kendew

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?

kendew

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?

pavroo

A different locales can be configured via:
~HOME/.config/obmenu-generator/config.pl
change:
"name_keys"           => ["Name"],
to your lang, for example pl_PL:
"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

kendew

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

pavroo

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

kendew

Just checking, and I don't want to be wasting your time, but you did use pl in the line
"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

pavroo

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

kendew

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. 

kendew

#10
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 sudo update-desktop-database ~/.local/share/applications

Kendew

kendew

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:
  "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 ~/.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:
# 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

pavroo

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

kendew

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 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 $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   "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 # 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.

kendew

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.

View the most recent posts on the forum