Giter Site home page Giter Site logo

Comments (17)

jvichub avatar jvichub commented on July 17, 2024

Forgot to mention, the iRate.bundle is in the 'copy resources' of the project.

from irate.

jvichub avatar jvichub commented on July 17, 2024

just for testing, i replaced the current 'localizedStringForKey' method with this older implementation:

- (NSString *)localizedStringForKey:(NSString *)key withDefault:(NSString *)defaultString
{
    static NSBundle *bundle = nil;
    if (bundle == nil)
    {
        //get localisation bundle
        NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"iRate" ofType:@"bundle"];
        bundle = [NSBundle bundleWithPath:bundlePath] ?: [NSBundle mainBundle];

        //get correct lproj folder as this doesn't always happen automatically
        for (NSString *language in [NSLocale preferredLanguages])
        {
            if ([[bundle localizations] containsObject:language])
            {
                bundlePath = [bundle pathForResource:language ofType:@"lproj"];
                bundle = [NSBundle bundleWithPath:bundlePath];
                break;
            }
        }

        //retain bundle
        bundle = [bundle ah_retain];
    }

    //return localised string
    return [bundle localizedStringForKey:key value:nil table:nil];
}

And it works, even though it's ignoring the defaultString.
I suppose there's a bug somewhere in the current implementation, but i don't know where exactly.

from irate.

nicklockwood avatar nicklockwood commented on July 17, 2024

Have you added a Localizable.strings file to your project and made sure that Portuguese is selected as a supported language in Project > Info?

If so, try doing a clean build from the Product menu - it may just be that you have a previously cached strings file from the old version.

from irate.

jvichub avatar jvichub commented on July 17, 2024

I had not.

I thought that was only required if i wanted to add/customize the localizations in the iRate bundle.

I've now added an empty Localization.strings, but i can't find the place where i'm supposed to select the supported languages (and do i have to manually add each of the languages supported by iRate? that doesn't seem to make sense to me).

In the Project->Info i just get the info that's in the app bundle. Is it there that i should edit?

I've read some people saying i should click on the Localization.strings, file inspector, and click on the "+" in the Localization, but there's no "+" in this version of Xcode (4.5). And it only let me add English as language.

from irate.

nicklockwood avatar nicklockwood commented on July 17, 2024

It used to be the case that iRate would be localised to all supported languages even if your project was not, but this is not what most people would want. Is it really the case that you have no text in your app that needs to be localised apart from iRate?

Here is a tutorial that includes screenshots of how to add new languages: http://www.aboveground.com/blog/xcode-4-4-and-localizable-strings-no-way-to-add-language

Note that this is the Info tab under Project, not under Targets.

from irate.

jvichub avatar jvichub commented on July 17, 2024

Ah yes, just found the right Info tab and it's working. Thank you for your help.

Yes i would like to localize my project, but not now, and i certainly wouldn't be able to localize it now to the many languages iRate supports. I think it's a bit of a hassle that iRate depends on that, but that's just my opinion.

from irate.

jvichub avatar jvichub commented on July 17, 2024

And i think, but i'm not sure, that iTunes will show to users that my project is localized to all those languages even though it's not, it's just iRate. But i'm not sure.

I don't know, i'm thinking about keeping locally the old implementation.

from irate.

nicklockwood avatar nicklockwood commented on July 17, 2024

The reasoning was that it's a bit odd to have mixed content in an app. If the rest of the app is in English, one particular modal should not be displayed in Russian, or whatever.

from irate.

nicklockwood avatar nicklockwood commented on July 17, 2024

It is true that iTunes will display all the languages you've added, but the idea is that you should only add support for the languages that you intend to localise your whole app for, and ignore the other ones that iRate supports.

from irate.

jvichub avatar jvichub commented on July 17, 2024

Really? I don't think it's odd at all. But maybe i'm wrong, i'll think about it for while.

For me it's like: there's the app, and there's iRate. As if iRate was a separate thing, almost like a native iOS dialog. The app can be english-only, but iOS is localized, and that's how iRate presents itself. It even looks like a native dialog.

And between connecting with the users in their own native language -- despite the app's english-only --, and being consistent about the language used, i think connecting with the users is more important.

from irate.

nicklockwood avatar nicklockwood commented on July 17, 2024

I may be able to add it back as an option. I'll think about it.

The previous solution was a pretty nasty hack, requiring me to basically bypass the standard localisation mechanism, pre-compile strings into binary plists, etc. The new solution is much cleaner and more compatible with how Apple intends it to work.

from irate.

jvichub avatar jvichub commented on July 17, 2024

I agree the old solution is more hack-ish. But what you get in the end is much better. I thought about it a little and i definitely think it was better before.

There are many examples of mixed languages in interfaces: if the app uses twitter/facebook sharing from iOS, it's going to appear localized. If it uses iOS stock buttons, they're going to appear localized. No matter what language the app is showing.

So basically, iRate should use whatever iOS is using. But i guess there's no API for that, and in that case, the old implementation at least gave the same results as if there was one API.

from irate.

nicklockwood avatar nicklockwood commented on July 17, 2024

OK, I have a solution that should work. Give me a little while.

from irate.

jvichub avatar jvichub commented on July 17, 2024

Sure. I must say the project, as it is, is really great.
Just thought i'd give my 2 cents about this new localization thing.

from irate.

nicklockwood avatar nicklockwood commented on July 17, 2024

OK, check out version 1.5.5. I think I've found a solution that should suit everyone.

from irate.

jvichub avatar jvichub commented on July 17, 2024

That worked great. Thanks, man.

from irate.

nicklockwood avatar nicklockwood commented on July 17, 2024

FYI, I've renamed 1.5.5 to 1.6, but it's the same code, in case you were wondering.

from irate.

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.