videos Youtube be seen with subtitles translated into the browser language

More
3 years 11 months ago #78732 by refacil
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:


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
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.


Thanks

Please Log in or Create an account to join the conversation.

More
3 years 11 months ago #78733 by refacil
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.

Please Log in or Create an account to join the conversation.

More
3 years 11 months ago #78735 by micker
hello i recommand to you to propose this code via a pr on github but we use oembed.com/ library to pars video
not sure is compatible

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
3 years 11 months ago #78738 by ggppdk
Hello

so you suggest that
- we modify the sharemedia field to add support that consider the current Joomla frontend language ?
so that the video will have subtitle in the language of that user is using ?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
3 years 11 months ago #78740 by refacil
If you want to modify the "Media" field, the proposal would be to create these options:

Your video is from Youtube.com ?: YES - NO

If so:

Do you want the videos to be subtitled ?: YES - NO (this option is subject to the video allowing it)

Code: "&cc_load_policy=1" or "& cc_load_policy=0"


Do you want the subtitles to be translated into the browser language ?: YES - NO (subject to availability of the language by the video provider)
Code: &hl=[variable]&cc_lang_pref=[variable]


Moment when you want to start the video
minute
second
Sample code: &start=1m20s


Moment when you want to end the video
minute:
second:
Sample code: &end=2m30s


Do you want related videos to be played ?: YES - NO
Code: "&rel=1" o "&rel=0"


Do you want the video to reproduce itself when entering the page?: YES - NO
Code: &autoplay=1” o “&autoplay=0”

There are other additional options

The template would look similar to this:

youtubeembedcode.com/en/

Please Log in or Create an account to join the conversation.

More
3 years 11 months ago #78744 by ggppdk
Hello

so you suggest to add a new parameter

Parameter Name: Set language of youtube URLs
Yes
No

Description
The current user's language will be set in youtube links,
so that this language will be used to select audio track and subtitle of this language (if these exist)


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.816 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline