Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8273923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:36:00+00:00 2026-06-08T07:36:00+00:00

I’m writing a small program (javascript, but I don’t think it matters) and am

  • 0

I’m writing a small program (javascript, but I don’t think it matters) and am trying to add translations to it.

The only strings in it that need to be translated are ‘Minimize’, ‘Maximize’, ‘Restore’, ‘Close’ etc — these should already have translations somewhere, right? Since when I right-click on a window’s system title bar I get a menu with these very same options (I’m using Linux).

Is there some way I can use these already-done translations instead of having to do them again (which involves me finding a whole bunch of translators happy to volunteer some time for the translation)?

Is it simply a matter of finding the right gettext domain? This is how I set it up at the moment (it is in javascript, but this is really irrelevant to the question):

const Gettext = imports.gettext.domain('foobar-gettext-domain');               
const _ = Gettext.gettext;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:36:01+00:00Added an answer on June 8, 2026 at 7:36 am

    OK, so on further reflection, I realised that I know how to use a pre-existing translation in gettext. To use a pre-existing text domain asdf, just do

    const Gettext = imports.gettext.domain('asdf');
    const _ = Gettext.gettext;
    

    No surprises there.

    It turned out that my actual problem was I wanted to use the translations for “Minimize”, “Maximize”, “Restore”, “Close”, etc, and I though I was sure these translations already existed on my system somewhere, I didn’t know what gettext domain they were actually in.

    To find this out:

    On Fedora (my version anyway), translated texts are in /usr/share/locale.

    I went into /usr/share/locale/en_GB/LC_MESSAGES and there are a bunch of .mo files there. These are not human-readable but I can still grep through them:

    [foo@bar]$ grep -i maximize *.mo
    Binary file devhelp.mo matches
    Binary file evolution-3.2.mo matches
    Binary file f-spot.mo matches
    Binary file gnome-games.mo matches
    Binary file gnome-media-2.0.mo matches
    Binary file gnome-utils-2.0.mo matches
    Binary file metacity.mo matches
    Binary file mutter.mo matches
    Binary file nautilus.mo matches
    

    Looking through the list, it occured to me that since I’m looking for translations of items on a window menu, it’s probably my window manager that owns those translations. My window manager (as I’m on gnome-shell) is mutter, which is based of metacity.

    So, I downloaded the mutter sources and looked in the po file (human-readable translation files), and lo and behold!

    #: ../src/ui/menu.c:69
    msgid "Mi_nimize"                                                               
    msgstr "Mi_nimise"                                                              
    
    #: ../src/ui/menu.c:71                                                          
    msgid "Ma_ximize"                                                               
    msgstr "Ma_ximise"                                                              
    
    #: ../src/ui/menu.c:73                                                          
    msgid "Unma_ximize"                                                             
    msgstr "Unma_ximise"                                                            
    
    ...and so on (the underscores are the keyboard accelerators for that menu item).
    

    So now that I’ve found the translations, it was simply a case of doing (in my code):

        const Gettext = imports.gettext.domain('mutter')
        const _ = Gettext.gettext;
    
        log(_("Ma_ximize")); // to translate 'Ma_ximize'
    

    (I have to feed in _("Ma_ximize") to gettext because that is the exact string that is translated in the mutter.mo file — there is no "Maximize" translation without the underscore. I had to remove the underscores from the translated text after, which might screw up languages that use underscores as part of their writing somehow, but I’m hoping that’s not many).

    So, in summary — it’s easy to use another (pre-existing) text domain, but the problem is finding the text domain that has the strings you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.