Nazar Abubaker
Nazar Abubaker

Reputation: 505

Trying to translate text, not working

$server_loc = $_SERVER['REQUEST_URI']; 

$locations = array( '/aiesec/ar/',
                    '/aiesec/ar/volunteer-abroad/',
                    '/aiesec/ar/about/',
                    '/aiesec/ar/working-abroad/',
                    '/aiesec/ar/stories/'
                  );

foreach ($locations as $loc) {

    if($server_loc == $loc) {
        $translate['apply'] = "قدم الآن";
        $translate['recent_stories'] = "قصص الأخيرة";
        $translate['instagram_feed'] = "إينستاجرام تغذية";
    } else {
        $translate['apply'] = "APPLY NOW";
        $translate['recent_stories'] = "RECENT STORIES";
        $translate['instagram_feed'] = "INSTAGRAM FEED";
    }

}

Hey all, Trying to get this simple code to work.

It's a very simple translation for a small website but for some reason, it refuses to work.

$server_loc works, as it'll echo '/aiesec/ar/' when I'm on the homepage.

Upvotes: 0

Views: 41

Answers (1)

NID
NID

Reputation: 3294

Why don't you use in_array

if(in_array($server_loc,$locations)){
        $translate['apply'] = "قدم الآن";
        $translate['recent_stories'] = "قصص الأخيرة";
        $translate['instagram_feed'] = "إينستاجرام تغذية";

}

Upvotes: 1

Related Questions