Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Multiple Sprachen

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
omexlu
Smarty Rookie


Joined: 13 Mar 2014
Posts: 27

PostPosted: Sun Aug 02, 2015 9:28 pm    Post subject: Multiple Sprachen Reply with quote

Hallo,

Ich habe vor meine Seite in 2 Sprachen darstellen zu lassen:
Code:
$smarty->configLoad('lang/de.conf');


Die Frage ist wie kann ich das nun am besten Lösen dass wenn der Besucher auf den Link für Englisch (?lang=en) klickt dass dies irgendwie gespeichert wird sowass der Nutzen nicht bei jedem Seitenaufruf den Link anklicken muss?

Danke im voraus
Back to top
View user's profile Send private message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 172
Location: Germany

PostPosted: Mon Aug 03, 2015 6:06 am    Post subject: Reply with quote

Hey,

sowas kannst du in Sessions (wenn Browser geschloschen, ist der gespeicherte Wert weg) oder in Cookies (Wert(e) weg, wenn Zeitabgelaufen ist, die du selbst bestimmen kannst oder der Benutzer alle Cookies selbst löscht) speichern und dann bei jedem aufruf auslesen. Wenn nichts vorhanden ist, nimmst du einfach den Standardwert (z. B. Deutsch)
Back to top
View user's profile Send private message Visit poster's website
omexlu
Smarty Rookie


Joined: 13 Mar 2014
Posts: 27

PostPosted: Mon Aug 03, 2015 6:34 am    Post subject: Reply with quote

Hast du ein Beispiel, gin ziemlich neu in der php scene Smile
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Aug 03, 2015 7:19 pm    Post subject: Reply with quote

Ich würde es zunächst einmal mit Cookies probieren.
Siehe http://php.net/manual/de/features.cookies.php

Der Code könnte so aussehen (nicht getestet)
Code:
$lang = 'de';
if (isset($_GET['lang'])) {
  $lang = $_GET['lang'];
  setcookie('lang', $_GET['lang'], time()+60*60*24*30);
} elseif (isset($_COOKIE['lang'])) {
   $lang = $_COOKIE['lang'];
}


time()+60*60*24*30 gibt an dass das Cookie 30 Tage lang gültig sein soll.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP