Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How come all of the examples are unilingual? #105

Closed
fritzblue opened this issue Apr 18, 2015 · 15 comments
Closed

How come all of the examples are unilingual? #105

fritzblue opened this issue Apr 18, 2015 · 15 comments

Comments

@fritzblue
Copy link

Just getting started with this library, and can't seem to find any code examples that provide more than one output language.

For example, the "comprehensive example" in the readme only includes English.

Am I missing something?

@redonkulus
Copy link
Member

@user453584 have you looked at the formatjs.io website? It offers more information and working examples which allow you to switch locales:

http://formatjs.io/react/

@fritzblue
Copy link
Author

These examples are helpful, but I'm so new that I feel like it a very basic "hello world" type example (e.g. translating "hello" to "hola") would still be helpful. Also, is there source for the examples on the site available on Github somewhere?

@jasonmit
Copy link
Contributor

@user453584 the website is open source as well https://github.com/yahoo/formatjs-site/

@ericf ericf added the support label Apr 20, 2015
@toolness
Copy link

toolness commented May 6, 2015

Hey, sorry if this isn't helpful, but I just wanted to +1 this issue--I've been scouring the formatjs.io website but can't find any documentation on the "schema" for the locales, formats, and messages properties mentioned in the react docs.

I get the impression that locales can be either a string or an array containing strings, but all the examples either set it to a string (e.g. "en-US") or an array containing a single string (e.g. ["en-US"]). It's not intuitive to me what might happen if I set it to an array containing multiple strings. This is probably the most confusing thing about figuring all this out: it's extremely hard to understand why the prop is called locales (plural) when every single example only contains one locale.

As for the messages prop, the Translating Strings section of the formatjs.io documentation shows this code snippet:

var messages = {
    en: {
        GREETING: 'Hello {name}'
    },
    fr: {
        GREETING: 'Bonjour {name}'
    }
};

The variable is called messages but the format seems to conflict with the structure of the messages prop in the examples, which doesn't seem to have a nested structure of locales (just the message names).

These conflicting concepts make it quite unintuitive for me to figure out what the "proper" way to provide data for multiple locales would be. I can certainly think of ways to make my app show different locales, but as @user453584 mentioned, a simple "hello world" style example would be really helpful.

Also, @redonkulus mentioned that the working examples on the website allow you to switch locales, which is great, but the actual source code listed for them--specifically, the definition of intlData in the "RENDER" tab of the examples--doesn't seem to actually include the JS/JSON for locales beyond en-US, or any of the logic for locale-switching. I can appreciate that this is probably done to make the examples less confusing, but having at least one working example of actual locale switching would be enormously helpful.

@ericf
Copy link
Collaborator

ericf commented May 7, 2015

Things should be less confusing in the next big release. Sorry.

@toolness
Copy link

toolness commented May 7, 2015

Ah, cool! Sorry, I didn't mean to sound ungrateful or anything--overall I really appreciate this tool and the documentation is excellent. This was just the one sticking point that was confusing me. 😁

Looking forward to the next release!

@rattrayalex
Copy link

+1
(happy to wait for next release, just want to make sure it's not forgotten)

@amackera
Copy link

+1 on this request! Love the library but would love some more comprehensive docs.

@ericf do you have any WIP docs we can look at? Or something to point us in the right direction? Happy to help out with this project also

@pconerly
Copy link

+1 tagging self for next release.

@cbarsony
Copy link

cbarsony commented Aug 5, 2015

I thought the same things what @toolness mentioned in his comment when I tried to figure out how to handle more languages, so a big +1!

@tracker1
Copy link

tracker1 commented Aug 5, 2015

+1 An example that used, for example en, en-UK, en-AU, sp and declaring a default language would be really nice.

en: Hello {name}!
en-UK: Greetings, {name}!
en-AU: G'day {name}!
sp: Buenos dias {name}!

@cbrwizard
Copy link

+1 for this

@petrbrzek
Copy link

+1

@ericf
Copy link
Collaborator

ericf commented Aug 24, 2015

No need for +1 comments.

@formatjs formatjs locked and limited conversation to collaborators Aug 24, 2015
@ericf
Copy link
Collaborator

ericf commented Sep 11, 2015

See: #162

@ericf ericf closed this as completed Sep 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests