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

react-native link does not work correctly #43

Closed
bezenson opened this issue Oct 19, 2016 · 26 comments
Closed

react-native link does not work correctly #43

bezenson opened this issue Oct 19, 2016 · 26 comments
Labels

Comments

@bezenson
Copy link

On iOS all fine. If device lang is ru then I see this locale. On android it is empty string. I've tested it on virtual device and real device.

See next code:

import I18n from 'react-native-i18n';
console.log('I18n', I18n);

2016-10-19 16 32 08

@Dakoso
Copy link

Dakoso commented Oct 20, 2016

+1 Same problem here

@bezenson
Copy link
Author

I think, I need to add that I use Android 6.0

@denvers
Copy link

denvers commented Oct 22, 2016

I use I18n.currentLocale() which works for me.

@bezenson
Copy link
Author

@denvers For me it returns "en", while phone is in "ru"

@bezenson
Copy link
Author

FIXED! Just don't use automatic setup via "link". Check your MainApplication.java for import of library and it's initializaition

@leventebalogh
Copy link

@inferusvv So you mean that the react-native link did not set it up correctly and you needed to correct it manually?

@bezenson
Copy link
Author

@leventebalogh yes, it doesn't work

@mmazzarolo
Copy link
Collaborator

mmazzarolo commented Nov 28, 2016

@inferusvv weird, which version on rn? :octocat:
it works for me

@dccarmo
Copy link

dccarmo commented Jan 20, 2017

This should be re-opened, it's still an issue and @inferusvv's solution is the correct one. Maybe the recipe for rnpm link needs to be updated?

@mmazzarolo mmazzarolo reopened this Jan 20, 2017
@wachunei
Copy link

wachunei commented Jan 25, 2017

I'm getting an empty locale too on iOS.
screen shot 2017-01-25 at 10 18 58 am

Update:

Digging deeper I modified line 6 of index.js and added console.log(RNI18n) and it logs undefined, thus an empty string is assigned to I18n.locale key.

@mmazzarolo
Copy link
Collaborator

mmazzarolo commented Jan 26, 2017

Hey there, can you provide some more info on the version of RN you're using?
I tried it on a bunch of different flavours and it worked correctly with react-native link :(

@wachunei
Copy link

wachunei commented Jan 26, 2017 via email

@mmazzarolo
Copy link
Collaborator

mmazzarolo commented Jan 26, 2017

Are you on i18n@1.0.0? You can unlink using react-native unlink react-native-i18n.

@wachunei
Copy link

wachunei commented Jan 26, 2017

Yes I am using 1.0.0.

I've unlink and link again and it is still returning undefined.

Tried npm uninstall then install again, link, and restart packager, still not working :(

Update

It isn't here, so I guess it didn't link correctly.
screen shot 2017-01-26 at 9 49 34 am

I added it manually now it works :)

@dkpalmer
Copy link

dkpalmer commented Feb 9, 2017

We encountered the same result as @wachunei, where we had to manually added lib for iOS.

RN 0.42.0rc, react-native-i18n 1.0.0.

@jjhesk
Copy link

jjhesk commented Feb 14, 2017

@wachunei how do we add and link the library manuallly on iOS? I opened up the xcode project workspace and go to see the project nagviator. I saw RN1I18n.xcodeproj is listed there. Does it mean i have the library linked?

@wachunei
Copy link

@jjhesk open ios/*.xcodproj project, then click on your project in the Project Navigator sidebar, click on Build Phases and expand Link Binary With Libraries section, libRNI18n.a should not be listed. Expand Libraries folder in Project Navigator, then RNI18n.xcodeproj » Products, grab libRNI18n.a and drop it into the Link Binary With Libraries list. You're done. Here's the official guide to Linking Libraries in iOS

@mmazzarolo mmazzarolo added the bug label Feb 21, 2017
@mmazzarolo mmazzarolo changed the title On android I18n.locale is empty. react-native link does not work correctly Feb 21, 2017
@mmazzarolo mmazzarolo mentioned this issue Feb 21, 2017
@mmazzarolo
Copy link
Collaborator

Hey all, I've been a bit busy lately.
Does anyone know what can be the source of this linking bug? It seems to happen since 0.40 🤔

@wachunei
Copy link

I'm kinda lost here, how do packages tell react-native link what to link to project?

@mmazzarolo
Copy link
Collaborator

mmazzarolo commented Feb 21, 2017

Same for me, I created some native libraries in the past (like this one) but react-native link has always worked out of the box for me on both Android and iOS.

Btw thank you @wachunei for all the support :)

@flq
Copy link

flq commented Feb 27, 2017

Just to state that I also had to manually add to the build phases (library was correctly added) testing on ios10 simulator with current i18n lib (^1.0.0)

@chemitaxis
Copy link

chemitaxis commented Mar 2, 2017

Ok, I have solved with a workaround (see this open issue by me): #53

You can add this (tested on iOS emulator) to solve the locale undefined or empty:
I18n.locale = I18n.currentLocale();

@wachunei
Copy link

wachunei commented Mar 7, 2017

Hey guys, I'm setting up a new project with this library and bug is still happening, just had to drag and drop libRNI18n.a manually to linked libraries. Android seems to work fine.

I think this is a non-minor bug and should me mentioned in README.md, because everyone is going to fall back to manual installation, not after a few tries and losing some time figure things out.

I have not found a way to specify react-native link exactly what to do to link this library correctly.

@mmazzarolo you're welcome, I'm glad to help.

@zoontek
Copy link
Collaborator

zoontek commented Mar 20, 2017

@wachunei I added a warning in the README.md. I investigate on the problem.

@zoontek
Copy link
Collaborator

zoontek commented Jun 16, 2017

Can you give a try on the v2.0.0? It should be fixed now 😃

@bezenson
Copy link
Author

@zoontek Some hours ago upgraded library. All fine 👍

@zoontek zoontek closed this as completed Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests