Language select page Logic


#1

Hi guyz,

I am trying to create a languauge Select page which should launch as first screen only when the app is launched for the first time and once the user has selected the language it should never come up again for any other launches of the ionic app.
Any Ideas???


#2

Use localStorage to save Selected language.
When app loads check if localStorage contains selected language or not.
If not then you can show language selection screen, else skip.


#3

Thank You…
Can you tell me how can I set the landing page to be language select page and skip code


#4

Verify if language is present or not in Device ready event and set the path accordingly. use this pah variable in your app.config


#6

Thank you … I ll try this…
Can you help me with path setting feature?
Should I use $state.go() if the language is present in Device Ready…
Is that enough to skip the language select page without coming up?


#7

In your Config function there will be some line indicating the default state as

$urlRouterProvider.otherwise(Path);

Now the path for this function will be the one you set in device ready

[Ensure Path variable is declared as global]


#8

thanks for the help…

$urlRouterProvider.otherwise(function(){
    var path = '';
    if (localStorage.getItem('appLanguage')) {
      path = '/playlists';
    } else {
      path = '/languageSelect';
    }
    return '/app'+path;
  });

I just did this and it works


#9

Good to hear.
That’s what i was saying :slight_smile:


#10

Can you please tell me how can I do this in IONIC 2?


#11

What do you mean by ‘this’? Please be specific.


#12

I meant to say that I have a language select page which should appear when the app is launched for the first time. Do you have any idea that how can I implement this in IONIC 2?


#13

You can use localStorage to store language selection.
When App loads, check in localStorage if selected lang is stored or not.
If not then shows Language selection page, else show your root page.


#14

@niravparsana94
Thanks for the solution.


#15

You can mark answer as solution so that future user will directly goto solution.