Jump to content

how to convert Swedish language to english using php

- - - - -

  • Please log in to reply
8 replies to this topic

#1
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Hi guys

i need a code for change Swedish language to english

for ex:
é = e
ö = o
ø = o

help please
thank you

#2
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
You want to translate, or simply change some char to the english equivalent?

#3
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
yes

#4
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
Normally, when someone give you a choise between option A and option B you don't answer with yes

#5
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
If you have the iconv function, you should be able to transliterate it in to the appropriate lettering:

<?php
$utf8_sentence = "é = e
ö = o
ø = o";
 
//set to your locale
setlocale(LC_CTYPE, 'en_US.UTF8');
 
 
//transliteration
echo iconv('UTF-8', 'ASCII//TRANSLIT', $utf8_sentence);

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#6
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd
Actually translating text into different languages is very hard. Your best chance is to use a API for a good translator (Google Translate).
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#7
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200

bbqroast said:

Actually translating text into different languages is very hard. Your best chance is to use a API for a good translator (Google Translate).

I believe he means "transliterate" (Write or print (a letter or word) using the closest corresponding letters of a different alphabet or language.) which is a fair bit easier. This can have its use in displaying foreign names in urls (.../Métis/ -> .../Metis) or ASCII neutralization.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#8
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
  • Location:/etc/passwd

Alexander said:

I believe he means "transliterate" (Write or print (a letter or word) using the closest corresponding letters of a different alphabet or language.) which is a fair bit easier. This can have its use in displaying foreign names in urls (.../Métis/ -> .../Metis) or ASCII neutralization.
Got it! There is a PHP function that takes a string and two arrays and then searches for letters (or words) in the string from the first array and replaces them with letters from the second array.
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#9
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200

bbqroast said:

Got it! There is a PHP function that takes a string and two arrays and then searches for letters (or words) in the string from the first array and replaces them with letters from the second array.

If the text is multibyte, it may see the first byte of the character as a letter and replace it or other things. PHP only sees unicode strings as separate bytes. It could be hard to do this however, so that is a valid solution although transliteration functions save almost all of the work provided you have them.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users