Correction so that the code is not changed by video image
Hello flexicontent friends
I am setting up a website looking for it to be visible in all languages, for this I am using joomla with flexicontent.
Then I installed a Google module that automatically translates the content into the language chosen by the user.
I created the Videos field in flexicontent.
So far so good.
The idea is that when a video is linked, only the YouTube video code is entered, example: J8iB9fPx7e8
This is the challenge: That the videos be seen with subtitles translated into the browser language.
For the subtitles to appear, add this code to the url of the video: & cc_load_policy = 1
For the subtitles to appear in a certain language, you must add this code:
& hl = en & cc_lang_pref = en (for English)
& hl = es & cc_lang_pref = es (for Spanish)
& hl = fr & cc_lang_pref = fr (for French)
etc.
I want two things:
Leave the URL prefix in the video field as default: https: //www. youtube. com/ embed/
and leave as a suffix
& hl = en & cc_lang_pref = en & cc_load_policy = 1
But I also want the language of the video subtitles "en", "es" or "fr" to be predetermined to the language of the browser
Is it possible to leave the prefix https:// www. youtube. com /embed/ and the suffix & hl = [variable] & cc_lang_pref = [variable] & cc_load_policy = 1 fixed in the video field?
Is there a way that I can add code to a flexicontent video field?
With this code the browser language is detected:
################################################## #######
# Copyright © 2008 Darrin Yeager #
#
www.dyeager.org/
#
# Licensed under BSD license. #
#
www.dyeager.org/downloads/license-bsd.txt
#
################################################## #######
function getDefaultLanguage () {
if (isset ($ _ SERVER ["HTTP_ACCEPT_LANGUAGE"])) {
return parseDefaultLanguage ($ _ SERVER ["HTTP_ACCEPT_LANGUAGE"]);
}
else {
return parseDefaultLanguage (NULL);
}
}
function parseDefaultLanguage ($ http_accept, $ deflang = "en") {
if (isset ($ http_accept) && strlen ($ http_accept)> 1) {
// divide the possible languages into an array
$ x = explode (",", $ http_accept);
foreach ($ x as $ val) {
// check the value q and create an associative array. If the q value does not exist, it is by default 1
if (preg_match ("/(.*); q = ([0-1] {0.1}. \ d {0.4}) / i", $ val, $ matches)) {
$ lang [$ matches [1]] = (float) $ matches [2];
}
else {
$ lang [$ val] = 1.0;
}
}
// return the default language which is the highest q value
$ qval = 0.0;
foreach ($ lang as $ key => $ value) {
if ($ value> $ qval) {
$ qval = (float) $ value;
$ deflang = $ key;
}
}
}
return strtolower ($ deflang);
}
The table would be:
hl = af Afrikaans
hl = ak Akan
hl = sq Albanian
hl = am Amharic
hl = ar Arabic
hl = hy Armenian
hl = az Azerbaijani
etc.