- #176
I like Serena
Homework Helper
MHB
- 16,336
- 258
Yep. (Nod)evinda said:Do we have to write a specific code to have also other languages besides english?
Yep. (Nod)evinda said:Do we have to write a specific code to have also other languages besides english?
Klaas van Aarsen said:Yep. (Nod)
Typically we would have an array in php that translates each english word into the target language.evinda said:I searched online and I found "set names utf8". Do we use this one? Or does it depend on the language we want to use? But how exactly is the code and where do we write this? Is this a part inside <?php ... ?> ?
Klaas van Aarsen said:Typically we would have an array in php that translates each english word into the target language.
Then, whenever we echo a word to the user, we would look it up in this array first.
Which words? (Wondering)evinda said:Only few words are not in english, the search button and some of the possible inputs.
What are you displaying in the search button? (Wondering)evinda said:The search button is displayed now as:
Which php content are you matching with the search input? (Wondering)evinda said:and when I give the non-english input they are not recognized although these words are also in the php content file.
Which languages do you want to support?evinda said:What do you mean to create an array. Should I write all the possible words in both languages?
Klaas van Aarsen said:Which words? (Wondering)
Klaas van Aarsen said:What are you displaying in the search button? (Wondering)
Klaas van Aarsen said:Which php content are you matching with the search input? (Wondering)
evinda said:If I write in the content.php file a greek word in place of "Phones" for example and then I give this word as an input in the searchbox, it is not identified and it gives the result that this input is not in the content file. But this happens only if I change "Phones" to an other word in greek. So it is related with the language, or not?
$language["Phones"] = " Τηλέφωνα"
.if ($deviceType == $language[$search]) { ... }
instead of if ($deviceType == $search) { ... }
. evinda said:Inside the button part I write the word "Αναζήτηση" but the result is as I showed above. Do we have to define the greek language first?
Do you only want so find exact matches for one of the top level words?evinda said:I check if the input is one of the top level words of the content.php file.
Klaas van Aarsen said:To match the Greek version, we can can first do$language["Phones"] = " Τηλέφωνα"
.
And then match it withif ($deviceType == $language[$search]) { ... }
instead ofif ($deviceType == $search) { ... }
.
Klaas van Aarsen said:No. I believe it means that your .php file has the wrong encoding. (Shake)
It should be in UTF-8.
Which editor do you use to edit the .php file? (Wondering)
I use Notepad++, which has a menu option Encoding, which shows that it is encoded in UTF-8.
Klaas van Aarsen said:Do you only want so find exact matches for one of the top level words?
Or also if the search string occurs in for instance the description of a device? (Wondering)
Ah right. (Blush)evinda said:Does this translation mean that if the at the content.php file we have "Phones"and if the input is "Τηλέφωνα" then it should be recognized as the same thing?
I don't mean it in this way. I mean that if in the content.php file I have a greek word, for example "Τηλέφωνα" and the input is "Τηλέφωνα" then I get a message that this product doesn't exist. But if I have in the content.php file the english word "Phones" and the input is "Phones" then I get the message that product exists. So the program desn't "understand" the greek language?
if ($language[$deviceType] == $search) { ... }
. $english["Τηλέφωνα"] = "Phones"
.
I guess so... I tested it and it worked just fine for me.evinda said:I use Notepad, and at "Save as"at Encoding also has UTF-8. So shouldn't the greek letters be correctly encoded?[/icode]
<meta charset="UTF-8">
in the <head></head> section of the html page that action.php generates.There is only one, isn't there?evinda said:Just in the top-level words.
Klaas van Aarsen said:I think we needforeach($content as $deviceType => $deviceAttributes)
for the top level.
It's not an array of arrays. (Shake)evinda said:Do we define this in this way because we have an array of arrays? Or in this way we define every array-element?
[ key => value, key => value ]
as opposed to [ value, value ]
. [ [ value, value ], [ value, value ] ]
, but that is not what we have.Klaas van Aarsen said:It's not an array of arrays. (Shake)
Instead it's because the array is of the form[ key => value, key => value ]
as opposed to[ value, value ]
.
An array of arrays would be of the form[ [ value, value ], [ value, value ] ]
, but that is not what we have.