Englisch Wort in deutsch anzeigen lassen

exxtreme

Grünschnabel
Nabend zusammen,

ich habe folgendes Problem. Und zwar habe ich ein Dropdown Menü "typ" und "farbe". Wenn man z.B. Typ 1 und Farbe Gelb wählt werden alle Bilder von einem Server angeziegt die folgenden Aufbau haben: typ1_gelb.jpg

So bin ich vorgegangen:

PHP:
$typ = array("typ1", "typ2", "typ3", "typ4"...
$colours = array("Blue", "Green", "Red", "Yellow"....

Ich kann jedoch nicht einfach Blue in Blau umbennenen da sich aus diesen Angaben die URL des Bildes zusammensetzt. Wie könnte ich es also realisieren, dass die Bilder weiterhin aus diesen Angaben angezeigt werden, jedoch unter dem Bild auf deutsch typ1 blau steht?
 
So richtig hab ichs nicht verstanden, aber vielleicht noch nen Array,mit den Übersetzungen? Dann such nach der Pos des Englischen Wortes und du hast das deutsche..

Gruß TvP
 
Du könntest auch einfach ein weiteres Array anlegen, dass die deutschen Wörter als Schlüssel besitzt und die Englischen als Wert.

PHP:
<?php

array(
  "blau" => "blue",
  "gelb" => "yellow"
);
?>
Demnach kriegst du dann den deutschen Namen der Farbe und setzt ihn einfach in den Arrayaufruf...
 
Meine Datei sieht jetzt wie folgt aus:

PHP:
<?php
$pets = array("Acara", "Aisha", "Blumaroo", "Bori", "Bruce", "Buzz", "Chia", "Chomby", "Cybunny", "Draik", "Elephante", "Eyrie", "Flotsam", "Gelert", "Gnorbu", "Grarrl", "Grundo", "Hissi", "Ixi", "Jetsam", "Jubjub", "Kacheek", "Kau", "Kiko", "Koi", "Korbat", "Kougra", "Krawk", "Kyrii", "Lenny", "Lupe", "Lutari", "Meerca", "Moehog", "Mynci", "Nimmo", "Ogrin", "Peophin", "Poogle", "Pteri", "Quiggle", "Ruki", "Scorchio", "Shoyru", "Skeith", "Techo", "Tonu", "Tuskaninny", "Uni", "Usul", "Wocky", "Xweetok", "Yurble", "Zafara");
$poses = array("Circle", "Happy", "Angry", "Sad", "Close Attack Left", "Ranged Attack Left", "Defended Left", "Hit Left", "Close Attack Right", "Ranged Attack Right", "Defended Right", "Hit Right", "Beaten", "Photo", "Happy Small", "Sad Small");

$colours = array("Pineapple", "Apple", "Aubergine", "Alien", "Avocado", "Baby", "Pear", "Biscuit", "Blueberry", "Blue", "Brown", "Darigan", "Disco", "Thornberry", "Durian", "Ice", "Electric", "Pea", "Strawberry", "Faerie", "Fire", "Spotted", "Yellow", "Speckled", "Split", "Ghost", "Striped", "Gold", "Grey", "Green", "Halloween", "Island", "Checkered", "Carrot", "Garlic", "Coconut", "Royalboy", "Royalgirl", "Clay", "Glowing", "Purple", "Lime", "Lutari", "Mallow", "Maraquan", "Msp", "Mutant", "Orange", "Pepper", "Peach", "Plum", "Pirate", "Plushie", "Custard", "Quigukiboy", "Quigukigir", "Rainbow", "Robot", "Pink", "Red", "Snot", "Shadow", "Snow", "Chocolate", "Sponge", "Silver", "Sketch", "Asparagus", "Gooseberry", "Starry", "Skunk", "Camouflage", "Tomato", "Grape", "Tyrannian", "Invisible", "Usukiboy", "Usukigirl", "Jelly", "Christmas", "White", "Cloud", "Desert", "Lemon");
$colours_de = array("Pineapple" => "Ananasige", "Apple" => "Apfel", "Aubergine" => "Auberginen", "Alien" => "Ausserirdische", "Avocado" => "Avocado", "Baby" => "Baby", "Pear" => "Birnige", "Biscuit" => "Biskuit", "Blueberry" => "Blaubeeren", "Blue" => "Blaue", "Brown" => "Braune", "Darigan" => "Darigan", "Disco" => "Disco", "Thornberry" => "Dornenbeeren", "Durian" => "Durian", "Ice" => "Eis", "Electric" =>"Elektro", "Pea" => "Erbsen", "Strawberry" => "Erdbeeren", "Faerie" => "Feen", "Fire" => "Feuer", "Spotted" => "Flecken", "Yellow" => "Gelbe", "Speckled" => "Gesprenkelt", "Split" => "Gespalten", "Ghost" => "Gespenster", "Striped" => "Gestreifte", "Gold" => "Goldene", "Grey" => "Graue", "Green" => "Grüne", "Halloween" => "Halloween", "Island" => "Inselige", "Checkered" => "Kariert", "Carrot" => "Karotte", "Garlic" => "Knoblauch", "Coconut" => "Kokosnussige", "Royalboy" => "Königlicher", "Royalgirl" => "Königliche", "Clay" => "Lehm", "Glowing" => "Leuchtende",
"Purple" => "Lila", "Lime" => "Limetten", "Lutari" => "Lutari", "Mallow" => "Mallow", "Maraquan" => "Maraqua", "Msp" => "Msp", "Mutant" => "Mutanten", "Orange" => "Orangene", "Pepper" => "Pfeffer", "Peach" => "Pfirsiche", "Plum" => "Pflaumenige", "Pirate" => "Piratische", "Plushie" => "Plüschie", "Custard" => "Pudding", "Quigukiboy" => "Quiguki Buberl", "Quigukigir" => "Quiguki Mäderl", "Rainbow" => "Regenbogen", "Robot" => "Roboter", "Pink" => "Rosa", "Red" => "Rote", "Snot" => "Rotzige", "Shadow" => "Schattige", "Snow" => "Schnee", "Chocolate" => "Schokolade", "Sponge" => "Schwammige", "Silver" => "Silberne", "Sketch" => "Skizzen", "Asparagus" => "Spargel", "Gooseberry" => "Stachelbeerige", "Starry" => "Sternen", "Skunk" => "Stinktier", "Camouflage" => "Tarnung", "Tomato" => "Tomaten", "Grape" => "Traube", "Tyrannian" => "Tyrannia", "Invisible" => "Unsichtbare", "Usukiboy" => "Usuki Buberl", "Usukigirl" => "Usuki Mäderl", "Jelly" => "Wackelpudding",
"Christmas" => "Weihnachts", "White" => "Weisse", "Cloud" => "Wolken", "Desert" => "Wüsten", "Lemon" => "Zitronen");

Die Ausgabe sieht so aus:

PHP:
".$colour." ".$pet." ".($date != -1? ("<br /><smallfont>".date("j F Y", $date)):"")."</smallfont>

Ich verstehe jedoch noch nicht so ganz, wie ich es nun hinbekomme, dass er mir die deutsche Übersetzung der Farbe ausgibt und nicht die englische.
 
Passe dein Formular entsprechend an, z. B. so:
PHP:
<?php
$colours = array("Pineapple", "Apple", "Aubergine", "Alien", "Avocado", "Baby", "Pear", "Biscuit", "Blueberry", "Blue", "Brown", "Darigan", "Disco", "Thornberry", "Durian", "Ice", "Electric", "Pea", "Strawberry", "Faerie", "Fire", "Spotted", "Yellow", "Speckled", "Split", "Ghost", "Striped", "Gold", "Grey", "Green", "Halloween", "Island", "Checkered", "Carrot", "Garlic", "Coconut", "Royalboy", "Royalgirl", "Clay", "Glowing", "Purple", "Lime", "Lutari", "Mallow", "Maraquan", "Msp", "Mutant", "Orange", "Pepper", "Peach", "Plum", "Pirate", "Plushie", "Custard", "Quigukiboy", "Quigukigir", "Rainbow", "Robot", "Pink", "Red", "Snot", "Shadow", "Snow", "Chocolate", "Sponge", "Silver", "Sketch", "Asparagus", "Gooseberry", "Starry", "Skunk", "Camouflage", "Tomato", "Grape", "Tyrannian", "Invisible", "Usukiboy", "Usukigirl", "Jelly", "Christmas", "White", "Cloud", "Desert", "Lemon");

$colours_de = array("Pineapple" => "Ananasige", "Apple" => "Apfel", "Aubergine" => "Auberginen", "Alien" => "Ausserirdische", "Avocado" => "Avocado", "Baby" => "Baby", "Pear" => "Birnige", "Biscuit" => "Biskuit", "Blueberry" => "Blaubeeren", "Blue" => "Blaue", "Brown" => "Braune", "Darigan" => "Darigan", "Disco" => "Disco", "Thornberry" => "Dornenbeeren", "Durian" => "Durian", "Ice" => "Eis", "Electric" =>"Elektro", "Pea" => "Erbsen", "Strawberry" => "Erdbeeren", "Faerie" => "Feen", "Fire" => "Feuer", "Spotted" => "Flecken", "Yellow" => "Gelbe", "Speckled" => "Gesprenkelt", "Split" => "Gespalten", "Ghost" => "Gespenster", "Striped" => "Gestreifte", "Gold" => "Goldene", "Grey" => "Graue", "Green" => "Grüne", "Halloween" => "Halloween", "Island" => "Inselige", "Checkered" => "Kariert", "Carrot" => "Karotte", "Garlic" => "Knoblauch", "Coconut" => "Kokosnussige", "Royalboy" => "Königlicher", "Royalgirl" => "Königliche", "Clay" => "Lehm", "Glowing" => "Leuchtende",
"Purple" => "Lila", "Lime" => "Limetten", "Lutari" => "Lutari", "Mallow" => "Mallow", "Maraquan" => "Maraqua", "Msp" => "Msp", "Mutant" => "Mutanten", "Orange" => "Orangene", "Pepper" => "Pfeffer", "Peach" => "Pfirsiche", "Plum" => "Pflaumenige", "Pirate" => "Piratische", "Plushie" => "Plüschie", "Custard" => "Pudding", "Quigukiboy" => "Quiguki Buberl", "Quigukigir" => "Quiguki Mäderl", "Rainbow" => "Regenbogen", "Robot" => "Roboter", "Pink" => "Rosa", "Red" => "Rote", "Snot" => "Rotzige", "Shadow" => "Schattige", "Snow" => "Schnee", "Chocolate" => "Schokolade", "Sponge" => "Schwammige", "Silver" => "Silberne", "Sketch" => "Skizzen", "Asparagus" => "Spargel", "Gooseberry" => "Stachelbeerige", "Starry" => "Sternen", "Skunk" => "Stinktier", "Camouflage" => "Tarnung", "Tomato" => "Tomaten", "Grape" => "Traube", "Tyrannian" => "Tyrannia", "Invisible" => "Unsichtbare", "Usukiboy" => "Usuki Buberl", "Usukigirl" => "Usuki Mäderl", "Jelly" => "Wackelpudding",
"Christmas" => "Weihnachts", "White" => "Weisse", "Cloud" => "Wolken", "Desert" => "Wüsten", "Lemon" => "Zitronen"); 

for($i = 0; $i < count($colours); $i++) {
	echo "<option value=".$colours[$i].">".$colours_de[$colours[$i]]."</option>";
}
?>
Er gibt dir also alle Options aus, das Value ist dabei die Englische Farbe, die Anzeige aber die Deutsche.
Auf der nächsten Seite gibst du dann einfach aus:
PHP:
<?php
echo $colours_de[$_POST['selectname']];
?>

Ist bestimmt nicht die eleganteste Lösung, aber mir fällt gerade nichts anderes ein.
 
Als Lösung für das Dropdown Menü eine Prima Sache. Er gibt, wie du sagtest alle Begriffe in deutsch aus. Jedoch ist das Problem mit der Ausgabe des Titels unterm Bild:

PHP:
echo("<td ".($class != "" ? ("class=\"".$class."\"") : "")."><a href=\"view.php?colour=".$colour."&amp;pet=".$pet."\"><img src=\"".$preurl.strtolower($pet)."_".strtolower($colour).$posturl."\" alt=\"\" /><br />".($withpn ? $posename : "")." ".$colour." ".$pet."</a>".($date != -1? ("<br /><smallfont>".date("j F Y", $date)):"")."</smallfont></td>");

".$colour." gibt also die Farbe (in englisch) aus und ".$pet." halt eine Species.
 
In der zweiten Datei definierst du $colours_de einfach auch und rufst es dann wie oben beschrieben auf:
PHP:
<?php

echo("<td ".($class != "" ? ("class=\"".$class."\"") : "")."><a href=\"view.php?colour=".$colours_de[$colour]."&amp;pet=".$pet."\"><img src=\"".$preurl.strtolower($pet)."_".strtolower($colours_de[$colour]).$posturl."\" alt=\"\" /><br />".($withpn ? $posename : "")." ".$colours_de[$colour]." ".$pet."</a>".($date != -1? ("<br /><smallfont>".date("j F Y", $date)):"")."</smallfont></td>");
?>
 
Zurück