Jump to content


Photo

How can I delete 'default' language?


  • Please log in to reply
17 replies to this topic

#1 Roman

Roman

    Newbie

  • Members
  • Pip
  • 2 posts
  • 1

Posted 25 March 2012 - 06:33 AM

Hi all!

First of all I want to say thanks for Ryan and all community for ProcessWire. It is really great!

I need to realize site with 2 languages support, for example English and Russian. I don't need to translate Admin, it is just for front-end proposes. I want to use multi-language fields and first segment of URL to detect front-end language.

I installed 'Languages Support' and 'Languages Support - Fields' modules, than added 'English' and 'Russian' languages on the Setup/Languages pages. So I don't need to 'Default' language anymore, but I can't delete it because there is no such function when I edit Default language page. I also can't rename it.

I hope anybody can help me with that problem.

#2 Michael Murphy

Michael Murphy

    Distinguished Member

  • Members
  • PipPipPip
  • 95 posts
  • 53

  • LocationBasel, Switzerland

Posted 25 March 2012 - 07:04 AM

Hi Roman,

I have also found the "Default" language setting confusing as it can't be renamed or deleted.
What I have done is used the "Default" as the main language and renamed the Title to English. Then added the second language as normal (eg. Name : de, Title : Deutsch).

It means that when I need to detect the current language in my code I use a snippet like this :

if($user->language->name == '' || $user->language->name == 'default') {

	// code for English

}
elseif($user->language->name == 'de') {

	// code for German

}

I am sure there is a more elegant solution, but this is what I managed to get working (still don't understand why user->language->name would equal blank, but it does when using the "language-gateway" technique described in the docs)

#3 diogo

diogo

    Hero Member

  • Moderators
  • 2,068 posts
  • 1179

  • LocationPorto, Portugal

Posted 25 March 2012 - 07:13 AM

Hi Roman Welcome to the forum!

There has to be a default language, PW needs it to know what to do in situations where it's not specified what language to use, but you can upload a new language to it and also change the title (just not the name). So, just choose one of the languages you need to be the default, and upload the files inside it.
Right now the default should be English. If you are happy with that, upload only the other languages, and leave it as it is.

Edit: same time as you Michael. Sorry for the repeated instructions :)

#4 Roman

Roman

    Newbie

  • Members
  • Pip
  • 2 posts
  • 1

Posted 25 March 2012 - 08:13 AM

Thank you guys, I got it.

In some reason I thought that in Ryan's examples I didn't see the 'default' language, so I thought that I am doing something wrong.

Problem solved, I'll use the default language as English.

Thanks again.

#5 ryan

ryan

    Hero Member

  • Administrators
  • 5,980 posts
  • 3380

  • LocationAtlanta, GA

Posted 25 March 2012 - 12:02 PM

Also wanted to add that you can do this:

if($user->language->isDefault()) {
    // user has the default language
}

Having a default language is required by the system, but it doesn't matter what language you decide for it to be. However, I would suggest making it whatever language the homepage of your site is in by default.

#6 jacmaes

jacmaes

    Distinguished Member

  • Members
  • PipPipPip
  • 55 posts
  • 23

  • LocationSeville, Spain

Posted 07 June 2012 - 12:07 PM

But how do you change the default language from English to another language? I'm building a site that has to be in Spanish by default (English would be the second choice).

It's probably simple, but I'm stuck. I've managed to get the correct language based on URL pre-segments (i.e. domain.com/es/ displays the site in Spanish and domain.com/en/ in English), but how can I display domain.com in Spanish by default?

Thanks

#7 apeisa

apeisa

    Hero Member

  • Moderators
  • 2,586 posts
  • 905

  • LocationVihti, Finland

Posted 07 June 2012 - 12:08 PM

Change the language for the guest user.

#8 jacmaes

jacmaes

    Distinguished Member

  • Members
  • PipPipPip
  • 55 posts
  • 23

  • LocationSeville, Spain

Posted 07 June 2012 - 12:44 PM

Man, that was so obvious, I feel like a fool. Thanks, apeisa. As always, PW is simpler than you'll assume it is.

#9 Soma

Soma

    Hero Member

  • Moderators
  • 3,397 posts
  • 1928

  • LocationSH, Switzerland

Posted 07 June 2012 - 12:53 PM

It's also possible to add a language pack to the default language, then have english as a secondary.
http://processwire.c...dule/#entry7501

@somartist | modules created | support me, flattr my work flattr.com


#10 jacmaes

jacmaes

    Distinguished Member

  • Members
  • PipPipPip
  • 55 posts
  • 23

  • LocationSeville, Spain

Posted 07 June 2012 - 02:43 PM

That makes more sense this way. Thanks Soma.

#11 doolak

doolak

    Sr. Member

  • Members
  • PipPipPipPip
  • 204 posts
  • 38

  • LocationGermany

Posted 19 December 2012 - 05:53 PM

Is there a possibility to delete a language pack or replace it?

With the additional languages it's no problem - you just have to delete the language with its language pack, add it again and add a new language pack.

But as the default language cannot be deleted it seems that you have to delete one translation file after the other - or is there another possibility?

Cheers,
Christian

#12 doolak

doolak

    Sr. Member

  • Members
  • PipPipPipPip
  • 204 posts
  • 38

  • LocationGermany

Posted 19 December 2012 - 06:06 PM

I have to correct myself:

Even with the additional languages it may be a problem - if you want to add a new language pack to an additional language, you can't delete it without loosing all the values of the language fields, if you use them. If you just add a new language pack it will be added to the previous one, not replace it.

So how would it be possible e.g. to replace a language pack with a newer version?

#13 ryan

ryan

    Hero Member

  • Administrators
  • 5,980 posts
  • 3380

  • LocationAtlanta, GA

Posted 21 December 2012 - 02:39 PM

Best bet is to delete the files you intend to replace by clicking the trash icon and then save. Then upload the new replacements.

#14 doolak

doolak

    Sr. Member

  • Members
  • PipPipPipPip
  • 204 posts
  • 38

  • LocationGermany

Posted 30 December 2012 - 07:46 PM

Would it be hard to implement an option to delete all the files at once?

#15 ryan

ryan

    Hero Member

  • Administrators
  • 5,980 posts
  • 3380

  • LocationAtlanta, GA

Posted 31 December 2012 - 01:58 PM

Not sure, but I'll check in to it next time I'm working with the files/images inputfields. It is relatively easy to do from the API though, as you can call $page->images->removeAll(); for example.

#16 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 827 posts
  • 217

  • LocationMidlands, UK

Posted 22 May 2013 - 12:32 PM

Change the language for the guest user.

 

Just come across this, where I can't change the default language because I get the following error:

 

The guest role is required

 

(it's greyed out)



#17 ryan

ryan

    Hero Member

  • Administrators
  • 5,980 posts
  • 3380

  • LocationAtlanta, GA

Posted 25 May 2013 - 06:32 AM

I'm not sure why it won't let you change the language for the guest user, but I'll look into it. However, I recommend aligning your guest user with the default language. The default language is specifically meant to be "whatever language is the default when the user hasn't selected one", in the same way that the guest user is mean to be a placeholder for when no user is present. As a result, the guest user and default language should ideally align. The default language can be whatever language you want it to be... there's no requirement that it be English or anything like that. 



#18 onjegolders

onjegolders

    Hero Member

  • Members
  • PipPipPipPipPip
  • 827 posts
  • 217

  • LocationMidlands, UK

Posted 26 May 2013 - 06:14 AM

Thanks Ryan, actually I think it's firing that error but changing the value anyway, so not such a big issue for me.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users