Locale : fr

328 views
Skip to first unread message

Denis Duval

unread,
Oct 8, 2019, 4:01:17 AM10/8/19
to Google Visualization API
Hello,
I want to change the Locale for my charts.
This code in the documentation does not work.
Can you help me ?
Thank you.

<h:head>
  <script type="text/javascript">
    google.charts.load('current', {'packages': ['corechart'], 'language': 'fr'});
...


Daniel LaLiberte

unread,
Oct 8, 2019, 9:01:20 AM10/8/19
to Google Visualization API
Hi Denis,

If you can provide a more complete example, we can probably figure out why you are not seeing the 'fr' locale work in your case.  Here is an example showing that it works for the Calendar.   https://jsfiddle.net/dlaliberte/64mrdvxL/

Note that text in your data and options are not translated for you.  Only the format of numbers, dates, times, and text generated by the charts themselves are localized.


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/00ed207b-322c-42f4-81f3-eebf78aa0d33%40googlegroups.com.


--

Denis Duval

unread,
Oct 8, 2019, 10:17:45 AM10/8/19
to Google Visualization API
thank you for your reply.

Here my code : 

HTML :

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:pe="http://primefaces.org/ui/extensions">
    <h:head>
        <title>Projet J.O.D</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <link type="text/css" rel="stylesheet" href="/javax.faces.resource/theme.css.xhtml?ln=primefaces-#{utilitaireManagerBean.themeCourant}"/>
        <link type="text/css" rel="stylesheet" href="CSS_Principal.css" media="screen"/>

        <!--Script utilisés pour les graphiques-->
        <script type="text/javascript" src="graphiqueGoogleChart.js"></script>
        <script type="text/javascript" src="graphiqueExporter.js"></script>

        <!--Chargement de Google Chart et 2 premiers graphiques-->
        <script type="text/javascript">
            //google.charts.load('current', {'packages': ['corechart']});
            google.charts.load('current', {'packages': ['corechart'], 'language': 'fr'});     <<<<<<<<<<<<< my charts are not displayed!
            google.charts.load('current', {'packages': ['annotationchart']});
            google.charts.setOnLoadCallback(espaceStandardFormationEvolutionEpargneDisponible);
            google.charts.setOnLoadCallback(espaceStandardNiveauEvolutionTroisEpargnes);
        </script>

        <!--Pour export d'un graphique au format PDF-->
        <script src="https://unpkg.com/jspdf@latest/dist/jspdf.min.js"></script>

        <script type="text/javascript">
            function noteMenuContextuelPosition()
            {
                var element = document.elementFromPoint(event.clientX, event.clientY);
                var parent = element.parentNode;
                rcNoteMenuContextuelPosition([
                    {name: 'menuTop', value: event.clientY},
                    {name: 'menuLeft', value: event.clientX},
                    {name: 'elementPage', value: element.innerHTML},
                    {name: 'elementParent', value: parent.id}
                ]);
            }
        </script>
        <script type="text/javascript">
            function noteDropPosition(event, ui)
            {
                rcNotePosition([{name: 'noteTop', value: ui.position.top}, {name: 'noteLeft', value: ui.position.left}]);
            }
        </script>
    </h:head>
    <h:body>
        <f:view> 
            <h:form id="form">                
                <p:outputPanel id="idPage" class="panelPage">

                    <div style="display: flex; width: 100%; margin-top: 70px">

                        <div id="idGraphiqueEspaceStandard1" style="margin-left: 0; width: 50%; height: 400px; border-right: 1px solid lightgrey"></div>

                        <div id="idGraphiqueEspaceStandard2" style="margin-right: 0; width: 50%; height: 400px"></div>

                    </div>
 ...

 

Daniel LaLiberte

unread,
Oct 8, 2019, 10:33:10 AM10/8/19
to Google Visualization API
Your code says:
            google.charts.load('current', {'packages': ['corechart'], 'language': 'fr'});     <<<<<<<<<<<<< my charts are not displayed!
            google.charts.load('current', {'packages': ['annotationchart']});

So you have two calls of google.charts.load, which is generally not a good idea, even if it works at all.  This may be the cause of your problem.  In any event, you will not be able to mix the two different language versions on the same page, with or without the language: 'fr' setting.    So I suggest combining them into one:

 google.charts.load('current', {'packages': ['corechart', 'annotationchart'], 'language': 'fr'}); 

If your charts are still not displaying, this is probably unrelated to the language: 'fr' setting, which you can prove by removing it.  Check your browser debugger console to see if there are any errors reported there.

If you really need two different language versions on the same page, you will have to hide one or the other chart in an iframe, to isolate it from the rest of the page.


--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.

Denis Duval

unread,
Oct 8, 2019, 1:22:53 PM10/8/19
to google-visua...@googlegroups.com
Ok. Thank you very much.

You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/I_jiBm43p2s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/CAOtcSJMS%3Dcd8AcfXq9X4HWGwqy-Znd2h5fp2xkb5GtkVMaaNqQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages