Announcement

Collapse
No announcement yet.

Select Drop Down Language Label

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Select Drop Down Language Label

    Hi there,

    I am setting up a multi language page in german and english. I am using Locales->Languages and all Labels work fine. Changing language button is on top of my form.

    1) Why isn't language selection drop down changing it's language? English by default?

    2) Now, how can I use Label with a SELECT Drop Down? Since SELECT form field is displaying the original database value I get "{lang_germany}" instead of "Germany" as I defined in languages. I thought about a work around. I set up a row for each language within my database and tried to work with a SELECT depending on active language, but I guess my my code is wrong and Variable of active language also. Help would be appreciated:

    Code:
    IF {lang} = "German" THEN
    SELECT db_select_country_id, country_de 
    FROM db_select_country
    ELSE
    IF {lang} = "English" THEN
    SELECT db_select_country_id, country_us 
    FROM db_select_country
    END

  • #2
    Re: Select Drop Down Language Label

    Ah...ok...tried some more...

    Lookup Method: Manual

    Single Value
    then add...
    Label {lang_us} Value {us}
    and also add label within languages
    {lang_us} = United States of America, Vereinigte Staaten von Amerika

    looks like this is the only way of achieving the language labeling right now

    Comment


    • #3
      Re: Select Drop Down Language Label

      Next problem...how can I do a dependency on 2 fields with this...for this I would need a SELECT statement which I can't use like this

      Country: us-Germany, de-Deutschland
      or
      Country: us-United States of America, de-Vereinigte Staaten von Amerika

      Next field Ajax reload

      State: Nordrhein-Westfalen, Bayern... (when Country = Germany)
      State: Alabama, Pennsylvania... (when Country = United States of America)

      Comment


      • #4
        Re: Select Drop Down Language Label

        So...I will go with Automatic SELECT again...I need code like this:

        Code:
        SELECT country, country_de
        FROM db_select_country
        WHEN {lang} = "German"
        ELSE
        SELECT country, country_us
        FROM db_select_country
        WHEN {lang} = "English"
        table: db_select_country
        ---------------------------------
        db_select_country_id | country | country_de | country_us
        ---------------------------------
        1 | Germany | Deutschland | Germany
        2 | United States of America | Vereinigte Staaten | United States

        Comment


        • #5
          Re: Select Drop Down Language Label

          next thing I tried looks like this...

          OnApplicationInit
          $my_language = sc_get_language();
          sc_set_global($my_language);

          OnRefresh
          $my_language = sc_get_language();
          sc_set_global($my_language);

          Now I need a SELECT which picks column depending on language "de" or "en_us"

          IF '[my_language]' = 'de' (SELECT db_select_country_id, country_de)
          ELSEIF '[my_language]' = 'en_us' (SELECT db_select_country_id, country_en_us)
          FROM db_select_country

          Comment


          • #6
            Re: Select Drop Down Language Label

            maybe it's easier and faster to create two forms? an english and german version?

            Switching between languages could be a custom button that calls the other form.

            Comment


            • #7
              Re: Select Drop Down Language Label

              Hey...thank you...yes...my first project based on this idea...then I discovered the language labels...so I am trying to have all languages in 1 form...all I need is the correct SQL SELECT STATEMENT...but I am not quiet sure if this will work the way I am trying:

              On my field country I also tried this
              Code:
              if ('[my_language]' = 'de', 1, 0) = 1) {
              SELECT db_select_country_id, country_de
              FROM db_select_country;}
              elseif ('[my_language]' = 'en_us', 1, 0) = 1) {
              SELECT db_select_country_id, country_en_us
              FROM db_select_country;}

              Comment


              • #8
                Re: Select Drop Down Language Label

                what's your database table definition?
                (the table holding your language texts).

                Comment


                • #9
                  Re: Select Drop Down Language Label

                  I want to have my table like this:

                  table: db_select_country
                  db_select_country_id (Int 11)| country_de (VARCHAR 256)| country_en_us (VARCHAR 256)
                  1 | Deutschland | Germany
                  2 | Vereinigte Staaten | United States

                  When '[my_language]' = de then
                  Select db_select_country_id, country_de

                  When '[my_language]' = en_us then
                  Select db_select_country_id, country_en_us

                  I tried all day long to come up with a solution on how to use different languages on Select Drop Down Field with Ajax dependency...first thing I tried was to use label definition within database, but Scriptcase just shows whats inside database and does not transform labels into different languages...thank you for your help so far...

                  Comment


                  • #10
                    Re: Select Drop Down Language Label

                    If I understand you correctly, you want to select a different column, depending on the value of global [my_language] ??

                    If that's what you want, then use CASE statement in SQL:

                    SELECT CASE when [my_language] = 'de'
                    THEN country_de
                    ELSE country_en_us
                    END
                    FROM db_select_country

                    (not sure if you need quotes around [my_language])

                    Comment


                    • #11
                      Re: Select Drop Down Language Label

                      and again some simple code solved my problem...thank you very much...this is solution to use multi language with select drop down using database lookup so ajax dependency will work:

                      OnApplicationInit
                      $my_language = sc_get_language();
                      sc_set_global($my_language);
                      echo $my_language;

                      OnLoad
                      $my_language = sc_get_language();
                      sc_set_global($my_language);
                      echo $my_language;

                      OnRefresh
                      $my_language = sc_get_language();
                      sc_set_global($my_language);
                      echo $my_language;

                      table: db_select_country
                      db_select_country_id (Int 11) | country (VARCHAR 256) | country_de (VARCHAR 256) | country_us (VARCHAR 256)
                      1 | Deutschland | Deutschland | Germany
                      2 | United States of America| Vereinigte Staaten | United States

                      table: db_select_state
                      db_select_state_id (Int 11) | country (VARCHAR 256) | state_de (VARCHAR 256) | state_us (VARCHAR 256)
                      1 | Deutschland | Bayern | Bayern
                      2 | United States of America | Alabama | Alabama

                      Application->Global Variables-> $my_language
                      Out

                      Select Statement "country"
                      SELECT country,(
                      CASE
                      WHEN '[my_language]' = 'de'
                      THEN country_de
                      WHEN '[my_language]' = 'en_us'
                      THEN country_us
                      END), country
                      FROM db_select_country

                      Select Statement Field "state"
                      SELECT (
                      CASE
                      WHEN '[my_language]' = 'de'
                      THEN state_de
                      WHEN '[my_language]' = 'en_us'
                      THEN state_us
                      END), (
                      CASE
                      WHEN '[my_language]' = 'de'
                      THEN state_de
                      WHEN '[my_language]' = 'en_us'
                      THEN state_us
                      END), country
                      FROM db_select_state
                      WHERE country = '{country}'

                      And don't forget to apply Ajax Reload within "country" field pointing on "state" field...hope this is helpful for anybody looking for a solution on this...took me 1 day to figure out best way

                      Comment

                      Working...
                      X