Code Monkey home page Code Monkey logo

Comments (7)

nwg-piotr avatar nwg-piotr commented on May 27, 2024 1

I think this should do the job:

std::string get_locale() {
    std::string l {"en"};
    if (getenv("LANG") != NULL) {
        char* env_val = getenv("LANG");
        std::string loc(env_val);
        if (!loc.empty()) {
            if (loc.find("_") != std::string::npos) {
                int idx = loc.find_first_of("_");
                l = loc.substr(0, idx);
            } else {
                l = loc;
            }
        }
    }
    return l;
}

from nwg-launchers.

nwg-piotr avatar nwg-piotr commented on May 27, 2024

Damn, I thought this had been fixed in #63 ...

from nwg-launchers.

santouits avatar santouits commented on May 27, 2024

check if getenv returns NULL, you can't catch that in an exception

from nwg-launchers.

nwg-piotr avatar nwg-piotr commented on May 27, 2024

Yeah, I tested by giving $LANG an empty string value. Never happened to me to have $LANG unset.

from nwg-launchers.

santouits avatar santouits commented on May 27, 2024

You wouldn't find it anyway, because it only happens in freebsd(or linux if you use the same library) because we use a different library for the string class there and it doesn't check if the c string you pass to std::string is NULL when you create one, so we should check it. In linux it checks and throws an std::logic_error.

from nwg-launchers.

jbeich avatar jbeich commented on May 27, 2024

2997dc9 works for me:

$ nwggrid
WM: sway
Locale: en
28 .desktop entries found
/home/foo/.config/nwg-launchers/nwggrid/style.css
Focused display: 0, 0, 3840, 2160
Time: 443

from nwg-launchers.

nwg-piotr avatar nwg-piotr commented on May 27, 2024

Thanks! Merging, if so.

from nwg-launchers.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.