Translate JS Messages

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcos

    #1

    Translate JS Messages


    I need to translate the messages of mine scripts, as I can make
    professionally this working with the pair php and javascript?

    Thank`s


    --
    Marcos.
    http://www.linuxhard.org
  • Evertjan.

    #2
    Re: Translate JS Messages

    Marcos wrote on 01 mrt 2005 in comp.lang.javas cript:
    [color=blue]
    > I need to translate the messages of mine scripts, as I can make
    > professionally this working with the pair php and javascript?[/color]

    Translate as in:

    alert('Hi folks')

    to

    alert('Bonjour a tous')

    ?

    If so what is your question?

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)

    Comment

    • Marcos

      #3
      Re: Translate JS Messages

      My question is, how do it with php and javascript, but the website it goes
      to have many languages.

      Thank's.

      Marcos

      Em 01 Mar 2005 14:18:09 GMT, Evertjan. <exjxw.hannivoo rt@interxnl.net >
      escreveu:
      [color=blue]
      > Translate as in[/color]

      Comment

      • David Dorward

        #4
        Re: Translate JS Messages

        Marcos wrote:
        [color=blue]
        > My question is, how do it with php and javascript, but the website it goes
        > to have many languages.[/color]

        The same way you translate the rest of your content - presumably through
        gettext.

        --
        David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
        Home is where the ~/.bashrc is

        Comment

        • Grant Wagner

          #5
          Re: Translate JS Messages

          "Marcos" <me@privacy.net > wrote in message
          news:opsmyxcaz9 44nt1j@rogerio. network...[color=blue]
          > My question is, how do it with php and javascript, but the website it
          > goes to have many languages.
          >
          > Thank's.
          >
          > Marcos
          >
          > Em 01 Mar 2005 14:18:09 GMT, Evertjan. <exjxw.hannivoo rt@interxnl.net >
          > escreveu:
          >[color=green]
          >> Translate as in[/color][/color]

          In index.html.en you'd have:

          <script type="text/javascript">
          var localizationRes ources = [ 'Hi folks', 'whatever', 'whatever' ];
          </script>

          In index.html.fr you'd have:

          <script type="text/javascript">
          var localizationRes ources = [ 'Bonjour a tous, 'whatever', 'whatever' ];
          </script>

          In all files you'd have:

          <script type="text/javascript">
          function greeting()
          {
          alert(localizat ionResources[0]);
          }
          // ...
          </script>

          The other thing to do is to use PHP to determine the language and
          dynamically write the correct client-side script:

          <?php
          // figure out what language the user is using
          if (they are using french) {
          $greeting = "french";
          } else if (they are using english) {
          $greeting = "english";
          }
          <script type="text/javascript">
          alert('<?php echo $greeting ?>');
          </script>

          I'd prefer the second method because then you don't need to dump all the
          localization resources to the client, you only produce the localization
          values you need.

          --
          Grant Wagner <gwagner@agrico reunited.com>
          comp.lang.javas cript FAQ - http://jibbering.com/faq


          Comment

          • Marcos

            #6
            Re: Translate JS Messages

            You they had helped very!

            Thank's.

            Em Tue, 01 Mar 2005 20:01:37 GMT, Grant Wagner
            <gwagner@agrico reunited.com> escreveu:
            [color=blue]
            > "Marcos" <me@privacy.net > wrote in message
            > news:opsmyxcaz9 44nt1j@rogerio. network...[color=green]
            >> My question is, how do it with php and javascript, but the website it
            >> goes to have many languages.
            >>
            >> Thank's.
            >>
            >> Marcos
            >>
            >> Em 01 Mar 2005 14:18:09 GMT, Evertjan. <exjxw.hannivoo rt@interxnl.net >
            >> escreveu:
            >>[color=darkred]
            >>> Translate as in[/color][/color]
            >
            > In index.html.en you'd have:
            >
            > <script type="text/javascript">
            > var localizationRes ources = [ 'Hi folks', 'whatever', 'whatever' ];
            > </script>
            >
            > In index.html.fr you'd have:
            >
            > <script type="text/javascript">
            > var localizationRes ources = [ 'Bonjour a tous, 'whatever', 'whatever' ];
            > </script>
            >
            > In all files you'd have:
            >
            > <script type="text/javascript">
            > function greeting()
            > {
            > alert(localizat ionResources[0]);
            > }
            > // ...
            > </script>
            >
            > The other thing to do is to use PHP to determine the language and
            > dynamically write the correct client-side script:
            >
            > <?php
            > // figure out what language the user is using
            > if (they are using french) {
            > $greeting = "french";
            > } else if (they are using english) {
            > $greeting = "english";
            > }
            > <script type="text/javascript">
            > alert('<?php echo $greeting ?>');
            > </script>
            >
            > I'd prefer the second method because then you don't need to dump all the
            > localization resources to the client, you only produce the localization
            > values you need.
            >[/color]



            --
            Marcos.
            http://www.linuxhard.org

            Comment

            Working...