transifex / transifex / addons / lotte / templates / translate.html

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
{% extends "projects/project_detail_childs.html" %}
{% load staticfiles %}
{% load humanize %}
{% load i18n %}
{% load permissions %}
{% load txcommontags %}
{% load addons %}

{% block breadcrumb %}
{% homelink %} »
<a href="{% url project_list_recent %}">{% trans "Projects" %}</a>
 » <a href="{% url project_detail project.slug %}">{{project}}</a>
{% if resource %} » <a href="{% url resource_detail project.slug resource.slug %}">{{resource}}</a>{% endif %}
» {% blocktrans with target_language.name as lang %}Translate to {{ lang }}{% endblocktrans %}
{% endblock %}

{% get_permission "project_perm.maintain" for request.user and resource.project as "is_maintainer" %}

{% block extra_head %}
{% get_permission "project_perm.proofread" for request.user and resource.project,target_language as "is_reviewer" %}

  <link media="screen" href="{% static "lotte/css/webtrans.css" %}" type="text/css" rel="stylesheet" />
  <link media="screen" href="{% static "lotte/css/dataTable.css" %}" type="text/css" rel="stylesheet" />
  <link media="screen" href="{% static "lotte/css/ui.tabs.lotte.css" %}" type="text/css" rel="stylesheet"/>
  <link media="screen" href="{% static "lotte/css/jquery.whitespaceHighlight.css" %}" type="text/css" rel="stylesheet"/>
  <link rel="stylesheet" type="text/css" media="screen" href="{% static "lotte/css/spellchecker.css" %}" />
  <!--[if IE]>
    <link media="screen" href="{% static "lotte/css/ie.lotte.css" %}" type="text/css" rel="stylesheet"/>
  <![endif]-->
  <script type="text/javascript" src="{% static "lotte/js/jquery.dataTables.min.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/jquery.dataTables.fnSetFilteringDaley.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/jquery.dataTables.customFullNumbersPagination.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/jquery.dotimeout.min.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/shortcut.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/tx.lotte2.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/footpanel.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/jquery.hoverIntent.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/jquery.whitespaceHighlight.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/jquery.textarea-expander.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/jquery.jeditable.mini.js" %}"></script>
  <script type="text/javascript" src="{% static "lotte/js/jquery.spellchecker.js" %}"></script>

  {% if RTL %}
    <style type="text/css">
        textarea.rtl{unicode-bidi: embed; direction: rtl;}
    </style>
  {% endif %}

<script type="text/javascript">

    /* Global variables */
    var autotranslate_url = '{% url autotranslate_proxy project.slug %}';
    var supportedlangs_url = '{% url supported_langs project.slug %}';
    {% if auto_translate %}
        var autotranslate_type = "{{ auto_translate.service_type }}";
    {% else %}
        var autotranslate_type = "";
    {% endif %}
    /* The instance of the StringSet class which has references to all the objects of the table */
    var stringset = null;
    /* Flags used for the auto-suggest function */
    var is_supported_source_lang = null;
    var is_supported_lang = null;
    /* DataTable instance var */
    var oTable;
    /* vars for string calcs */
    var translated;
    var untranslated;
    var reviewed;
    var translated_strings = {{ translated_strings }};
    var untranslated_strings = {{ untranslated_strings }};
    var reviewed_strings = {{ reviewed_strings }};
    var total_strings = translated_strings + untranslated_strings;
    /* obj for holding default values of edited text areas. works like a hastable/dict */
    var current_defaults = {};
    /* var to keep filter state */
    {% if untranslated_strings %}
        var filter_var = "untranslated,";
    {% else %}
        var filter_var = null;
    {% endif %}
    var user_filters_values = null;
    var resource_filters_values = null;
    var more_languages_values = null;
    /* url for details requests */
    /* FIXME: Find a more clever way to do this resolving. */
    var tab_details_urlp_tmpl = "{% url tab_details_snippet 1111111111 target_language.code %}";
    var tab_suggestions_urlp_tmpl = "{% url tab_suggestions_snippet 1111111111 target_language.code %}";
    /* Global vars holding the source and target language codes */
    var source_lang = '{{ resource.source_language.code }}';
    var target_lang = '{{ target_language.code }}';
    var saveError_response = false;
    var spellcheck_langs = [{% for item in spellcheck_supported_langs %}"{{ item }}"{% if not forloop.last %}, {% endif %}{% endfor %}];
    if ($.inArray("{{target_language.code}}", spellcheck_langs) >= 0) {
    	var spellcheck_url = '{% url spellcheckurl project.slug resource.slug target_language.code %}';
    	var enable_spellcheck = true;
    } else {
    	var enable_spellcheck = false;
    }
    // Used to manage extra tabs
    var toolbars = [];
    toolbars[0] = ['lotte', lotte_tabs];

    function onWindowCloseOrLoad(e) {
        if (!$("#toggle_autosave").is(":checked") && lotteStatus.updated){
            e = e || window.event;
            var message = "Do you really want to leave Lotte? Data you have entered may not be saved.";
            // For IE and Firefox prior to version 4
            if (e) {
                e.returnValue = message;
            }

            // For Safari
            return message;
        }
    }

    $(window).bind('beforeunload', onWindowCloseOrLoad);

    $(window).bind('unload', function() {
        if ($("#toggle_autosave").is(":checked")){
            $('#save_and_exit').click();
        }
    });

    function unique(arr){
        /* Drop duplicated entries from an array (list) */
        var retval = new Array();
        for(var i = 0; i < arr.length ; i++) {
            // `if a[i] not in retval`
            if(retval.indexOf(arr[i]) == -1) {
                retval.push(arr[i]);
            }
        }
        return retval;
    }

    function saveError(){
        /*
        Global function used by the custom jquery.dataTables pagination plugin
        for checking for errors when saving entries before changing page.
        */
        if (stringset.translated_modified || stringset.untranslated_modified ) {
            stringset.error = false;
            stringset.push();
            if (stringset.error) {
                var r = confirm('{% trans "There is at least one entry with error that was not saved. Do you want to continue anyway?"|escapejs %}');
                if (! r)
                    return true;
            }
        }
        return false;
    }


    function aroundPagination(oSettings, fnCallback){
        /*
        Global function used by the custom jquery.dataTables pagination plugin
        for placing the page on the top of the table when changing page.
        */
        $("div.dataTables_wrapper").hide();

        fnCallback(oSettings);

        //$("html, body").animate({ scrollTop: $("div#content").offset().top}, 500);
        $("div.dataTables_wrapper").show('slow');
    }


    /* document ready. do stuff */
    $(document).ready(function(){

        oTable = $('#stringset_table').dataTable({
            "oLanguage": {
                "sProcessing":   '{% trans "Processing..."|escapejs %}',
                "sLengthMenu":   '{% trans "Show _MENU_ entries"|escapejs %}',
                "sZeroRecords":  '{% trans "No matching records found"|escapejs %}',
                "sInfo":         '{% trans "Showing _START_ to _END_ of _TOTAL_ entries"|escapejs %}',
                "sInfoEmpty":    '{% trans "Nothing to show"|escapejs %}',
// XXX "(excluding _EXCLUDED_ entries)"
                "sInfoFiltered": '{% trans "(filtered from _MAX_ total entries)"|escapejs %}',
                "sInfoPostFix":  "",
                "sSearch":       '{% trans " "|escapejs %}',
                "sUrl":          "",
                "oPaginate": {
                        "sFirst":    '{% trans "First"|escapejs %}',
                        "sPrevious": '{% trans "Previous"|escapejs %}',
                        "sNext":     '{% trans "Next"|escapejs %}',
                        "sLast":     '{% trans "Last"|escapejs %}'
                }
            },
            "bJQueryUI": false,
            "sPaginationType": "customFullNumbers",
            "aaSorting": [[ 0, "asc" ]],
            "bServerSide": true,
            "bProcessing": true,
            "iDisplayLength": 50,
            {% if resource %}
                "sAjaxSource": "{%  url stringset_handling project.slug resource.slug target_language.code %}",
            {% else %}
                "sAjaxSource": "{%  url stringset_handling project.slug target_language.code %}",
            {% endif %}
            "sDom": '<"top"fi><"clear">rt<"bottom"pl><"clear">',
            "bAutoWidth": false,
            "aoColumns" : [
                // Holds the Translation id (hidden)
                { "bVisible":false },
                // Holds the SourceEntity string
                { "bVisible":false, "bSortable": false, },
                // Holds the source Translation string/s mapped to the plural rules
                // It may also hold the similar language translations.
                { "sClass": "msg", "asSorting": [ "desc", "asc" ],  "sWidth": "350px",
                  "fnRender": function(oObj){
                    // Escape recursively all the strings in the array
                    var clean_array = array_escape({"key":oObj.aData[1], "source_dict":oObj.aData[2]});
                    var source_divs = '';
                    var plurals_counter = 0;
                    var plural_types = ['zero', 'one', 'two', 'few', 'many', 'other']
                    // Provide the necessary html fragment for each plural rule
                    for(rule in plural_types){
                        if(plural_types[rule] in clean_array["source_dict"]["source_strings"]){
                            if(plural_types[rule]=='other'){
                              source_divs += '<div class="source_string" id="sourcestring_'+ oObj.iDataRow +'">';
                              if(plurals_counter>0)
                                source_divs += '<span class="plural_title">'+plural_types[rule]+': </span>'
                              source_divs += html_escape(clean_array["source_dict"]["source_strings"][plural_types[rule]]) + '</div>'
                            }else
                              source_divs += '<p class="source_string_plural" rule="'+plural_types[rule]+'"><span class="plural_title">'+plural_types[rule]+': </span>' + html_escape(clean_array["source_dict"]["source_strings"][plural_types[rule]]) + '</p>'
                            plurals_counter++;
                        }
                    }

                    // If we have pluralized translation row, indicate this with a label.
                    var plural_indicator = '';
                    if(plurals_counter>1)
                        plural_indicator = '<div class="plural_indicator">Pluralized Translations</div>';

                    // Concatenate the similar language translations with the
                    // html fragment which holds the source strings.
                    for(lang in clean_array["source_dict"]["similar_lang_strings"]){
                      lang_strings = "";
                      for(rule in clean_array["source_dict"]["similar_lang_strings"][lang]){
                        if(rule=='other')
                          lang_strings += '<p>' + html_escape(clean_array["source_dict"]["similar_lang_strings"][lang][rule]) + '</p>'
                        else
                          lang_strings += '<p><span class="plural_title">'+rule+': </span>' + html_escape(clean_array["source_dict"]["similar_lang_strings"][lang][rule]) + '</p>'
                      }
                      if(!lang_strings==""){
                        source_divs += '<h3 class="similar_lang_title">In '+lang+':</h3>';
                        source_divs += lang_strings;
                      }
                    }

                    // Provide the amount (number) of suggestions and a
                    // bold flag to be used in case we have empty translation
                    // textareas.
                    var suggestions_num = '';
                    if(oObj.aData[4] > 0)
                        suggestions_num = ' ('+oObj.aData[4]+')';
                    var bold_flag = false;
                    if(suggestions_num!='' && oObj.aData[3]['other']=='')
                        bold_flag = true;

                    // Concatenate the plural indicator, the (hidden) key,
                    // the source strings and the row tabs.
                    tabs = '<div class="source_string_wrapper">'
                           + plural_indicator
                           + ' <div class="source_entity nodisplay" id="sourceentity_'+ oObj.iDataRow +'" ><span title="{% trans "Key" %}">'+ clean_array["key"] +'</span></div>'
                           + source_divs
                           + ' <div class="row_tabs">'
                           + '  <ul>'
                           + '    <li>'
                           + '     <a class="tabs_trigger show_details" href="#">{% trans "details" %}</a>'
                           + '    </li>'
                           + '    <li>'
                           + '     <a class="tabs_trigger show_suggestions" href="#">'+(bold_flag?'<strong>':'')+'{% trans "suggestions" %}'+suggestions_num+(bold_flag?'</strong>':'')+'</a>'
                           + '    </li>';
                           
                    // Must contain something like: tabs += '<li><a>foo</a></li>'
                    {% hook "tab_lotte.html" tab %}

                    tabs += '  </ul>'
                           + ' </div>'
                           + '</div>';
                    return tabs
                  }
                },
                // Holds the target Translation string/s mapped to the plural rules
                { "sClass": "trans", "bSortable": false,  "sWidth": "350px",
                  "fnRender": function(oObj){
                      // Escape recursively all the strings in the array
                      var clean_array = array_escape({"translations":oObj.aData[3]});
                      var textareas = '';
                      var plural_types = ['zero', 'one', 'two', 'few', 'many', 'other'];
                      var plurals_counter = 0;
                      // Provide the necessary html fragment for each plural rule
                      for(rule in plural_types){
                          if(plural_types[rule] in clean_array["translations"]){
                              translation_text = html_escape(clean_array["translations"][plural_types[rule]]);
                              if (translation_text[0] == '\n')
                                  translation_text = '\n' + translation_text;
                              else if (translation_text.substr(0, 2) == '\r\n')
                                  translation_text = '\r\n' + translation_text;
                              if(plural_types[rule]=='other'){
                                  textareas += '<div class="translation_wrapper"><span class="rule nodisplay" rule="'+plural_types[rule]+'">'+plural_types[rule]+'</span><textarea class="translation {% if RTL %}rtl {% endif %}default_translation" id="translation_' + oObj.iDataRow + '">' + translation_text + '</textarea>';
                                if(plurals_counter>0)
                                    textareas += '<span class="plural_label tag" title="Translation plural form for '+plural_types[rule]+' items (equation: {{ target_language.rule_other}})">'+plural_types[rule]+'</span>';
                                textareas += '</div>';
                              }else{
                                textareas += '<div class="translation_wrapper"><span class="rule nodisplay" rule="'+plural_types[rule]+'">'+plural_types[rule]+'</span><textarea class="translation {% if RTL %}rtl {% endif %}">' + translation_text + '</textarea>';
                                if(plural_types[rule]=='zero'){
                                    textareas += '<span class="plural_label tag" title="Translation plural form for '+plural_types[rule]+' items (equation: {{ target_language.rule_zero }})">'+plural_types[rule]+'</span>';
                                }else if(plural_types[rule]=='one'){
                                    textareas += '<span class="plural_label tag" title="Translation plural form for '+plural_types[rule]+' item (equation: {{ target_language.rule_one }})">'+plural_types[rule]+'</span>';
                                }else if(plural_types[rule]=='two'){
                                    textareas += '<span class="plural_label tag" title="Translation plural form for '+plural_types[rule]+' items (equation: {{ target_language.rule_two }})">'+plural_types[rule]+'</span>';
                                }else if(plural_types[rule]=='few'){
                                    textareas += '<span class="plural_label tag" title="Translation plural form for '+plural_types[rule]+' items (equation: {{ target_language.rule_few }})">'+plural_types[rule]+'</span>';
                                }else if(plural_types[rule]=='many'){
                                    textareas += '<span class="plural_label tag" title="Translation plural form for '+plural_types[rule]+' items (equation: {{ target_language.rule_many }})">'+plural_types[rule]+'</span>';
                                }
                                textareas += '</div>';
                              }
                              plurals_counter++;
                          }
                      }

                      // Concatenate translation textareas with action buttons
                      textareas += '<div class="error_notes"></div>'
                      + '<div class="lotte-actions">'
                      {% if auto_translate %}
                           textareas += '  <p id="auto_translate_wrapper"><a class="i16 buttonized action suggest">{% trans "auto translate" %}</a></p>'
                      {% endif %}
                      textareas += '  <p id="copy_source_wrapper"><a class="i16 buttonized  copy_source">{% trans "copy source" %}</a></p>'
                      + '</div>';
                      return textareas;
                    }
                },
                // Holds the amount of Suggestions provided for this source string/s
                { "bVisible":false, "bSortable": false, },
                // Holds an HTML snippet for save, undo buttons and hidden context
                { "sClass": "notes", "bSortable": false, "bVisible":true, "sWidth": "40px",},
                {% if is_reviewer %}
                { "sClass": "notes", "bSortable": false, "bVisible":true, "sWidth": "40px",},
                {% endif %}
            ],
            "fnServerData": function (sSource, aoData, fnCallback) {

              /*
               * Here we issue the AJAX request to get the table data and
               * then we create the StringSet object which holds all the
               * Translation objects in memory.
              */

              // Show the loading indicator
              $("div#notification-container div").html('{% trans "Loading strings..."|escapejs %}');
              $("div#notification-container").fadeIn("slow");

              // Add filtering parameters to the POST data dictionary
              if (filter_var) {
                aoData.push( { "name" : "filters", "value": filter_var});
              }
              if (user_filters_values){
                aoData.push( { "name" : "user_filters", "value": user_filters_values});
              }
              if (resource_filters_values){
                aoData.push( { "name" : "resource_filters", "value": resource_filters_values});
              }
              if (more_languages_values){
                aoData.push( { "name" : "more_languages", "value": more_languages_values});
              }

              // Issue the actual AJAX request to fetch the data to be rendered.
              $.ajax ( {
                  "dataType": 'json',
                  "type": "POST",
                  "url": sSource,
                  "data": aoData,
                  "complete": function(xmlhttpreq, status) {

                    /*
                     * When we have the data, create the Stringset instance and
                     * trigger the fnDrawCallback to render one by one the rows!
                    */

                    var parsed_data = JSON.parse(xmlhttpreq.responseText);
                    var push_url = '{% url push_translation project.slug target_language.code %}';

                    // Fill the statistics variable
                    if ( stringset ) {
                        // Modified strings should be saved or dropped on page change.
                        translated = stringset.translated; // - stringset.translated_modified;
                        untranslated = stringset.untranslated; // - stringset.untranslated_modified;
                        reviewed = stringset.reviewed;
                    } else {
                        translated = translated_strings;
                        untranslated = untranslated_strings;
                        reviewed = reviewed_strings;
                    }

                    // Create StringSet instance
                    stringset = new StringSet(parsed_data, push_url, '{{resource.source_language}}', '{{target_language.code}}');
                    stringset.translated = translated;
                    stringset.untranslated = untranslated;
                    stringset.reviewed = reviewed;

                    // Draw the table
                    fnCallback(parsed_data);

                    // Hide the loading indicator
                    setTimeout('$("div#notification-container").fadeOut();',1000);

                    }
                  });

             },
            "fnDrawCallback": function() {

                // Put the table object as an class attribute in StringSet.
                stringset.bindToTable("stringset_table");

                // Draw the colors for textareas and hide/show save buttons
                stringset.updateColors_Buttons();

                // Enable the onkeyup mark as modified and show save button
                stringset.bindKeyupTextArea();

                // Enable the onfocus "make current in StringSet"
                stringset.bindFocusTextArea();

                if ($("#toggle_autosave").is(":checked")){
                    // Enable the save button push upstream.
                    stringset.bindBlurTextArea();
                } else {
                    stringset.unbindBlurTextArea();
                }
                var push_url = '{% url push_translation project.slug target_language.code %}';

                if ($("#toggle_verbose").is(":checked")){
                    // Enable the save button push upstream.
                    $('.source_entity').show();
                } else {
                    $('.source_entity').hide();
                }

                // Statistics and filtering by flag table
                stringset.bindStatsAndFilter("stats_table");
                stringset.updateStats(); /* Update statistics */

                // Bind toolbar
                stringset.toolbar();

                stringset.current_box = null;

                // Highlight source strings.
                $('.source_string, .source_string_plural').whitespaceHighlight();

                // Auto expanding textareas.
                $("textarea.translation").each(function(index) {
                    var $row = $(this).parents('tr');
                    var $srcDiv = $row.find('.source_string').first();
                    var srcHeight = $srcDiv.height();
                    var textareaHeight = $(this).height();
                    if (textareaHeight < srcHeight)
                        $(this).TextAreaExpander(srcHeight);
                });
	    }
        }).fnSetFilteringDelay(500);

        {% if is_reviewer %}

        {% if resource %}
        var proofread_url = '{% url proofread project.slug resource.slug target_language.code %}';
        {% else %}
        var proofread_url = '{% url proofread project.slug target_language.code %}';
        {% endif %}

        $('.review-check').live('change', function(){
            var sid = $(this).attr('id').split('_')[2];
            var req, up;

            if ($(this).attr('checked')) {
                req = {'true': [sid]};
                up = true;
            } else {
                req = {'false': [sid]};
                up = false;
            };

            $.ajax({
                type: 'POST',
                url: proofread_url,
                data: JSON.stringify(req),
                success: function() {
                  if (up) {
                    stringset.reviewed += 1;
                  } else {
                    stringset.reviewed -= 1;
                  }
                  stringset.updateStats();
                }
            });
        });

        $('#review-all').live('change', function() {
          var checked = $(this).attr('checked');
          var ids_checked = [];
          var ids_unchecked = [];
          $('.review-check').each(function() {
            if (!$(this).attr('disabled')) {
              if (checked) {
                $(this).prop('checked', true);
                ids_checked.push($(this).attr('id').split('_')[2]);
              } else {
                $(this).prop('checked', false);
                ids_unchecked.push($(this).attr('id').split('_')[2]);
              }
            }
          })

          var data = {
            'true': ids_checked,
            'false': ids_unchecked
          };
          $.post(proofread_url, JSON.stringify(data));
        });
        {% endif %}

		function addShortcuts() {
			// next page
			shortcut.add('Alt+l', function(evt) {
				if (stringset.current_box) {
					stringset.current_box.blur();
				}
				oTable.fnPageChange('next');
			}, {'type':'keydown',});

			// previous page
			shortcut.add('Alt+j', function(evt) {
				if (stringset.current_box) {
					stringset.current_box.blur();
				}
				oTable.fnPageChange('previous')
			}, {'type':'keydown',});

			// row up
			shortcut.add('Alt+i', function(evt) {
				if (!stringset.current_box) {
					$("#stringset_table").find('tr:not(.metatr):last-child').find('textarea.default_translation').focus();
				} else {
					stringset.current_box.blur();
					stringset.current_box.parents('.trans').parent().prevAll(':not(.metatr):first').find('textarea.default_translation').focus();
				}
			}, {'type':'keydown',});

			// row down
			shortcut.add('Alt+k', function(evt) {
				if (!stringset.current_box ) {
					$("#stringset_table").find('tr:not(.metatr):nth-child(1)').find('textarea.default_translation').focus();
				} else {
					stringset.current_box.blur();
					stringset.current_box.parents('.trans').parent().nextAll(':not(.metatr):first').find('textarea.default_translation').focus();
				}
			}, {'type':'keydown',});

			// copy source
			shortcut.add('Alt+g', function(evt) {
				if (!stringset.current_box) {
					return false;
				}
				stringset.current_box.parents('.trans').find(".copy_source").click();
			});

			// auto translate
			shortcut.add('Alt+t', function(evt) {
				if (!stringset.current_box) {
					return false;
				}
				stringset.current_box.parents('.trans').find(".suggest").click();
			});
		}
		addShortcuts();

		function removeShortcuts() {
			shortcut.remove('Alt+l');
			shortcut.remove('Alt+j');
			shortcut.remove('Alt+i');
			shortcut.remove('Alt+k');
			shortcut.remove('Alt+g');
			shortcut.remove('Alt+t');
		}

        $("#toggle_shortcuts").click( function() {
            if ($(this).is(":checked")){
				addShortcuts();
			} else {
				removeShortcuts();
			}
		});
        $("#toggle_autosuggestions").click( function() {
            if ($(this).is(":checked")){
				window.autosuggestions = true;
			} else {
				window.autosuggestions = false;
			}
		});

        /* SETTINGS togglers */
        $("#toggle_verbose").click( function() {
            if ($(this).is(":checked")){
                $('.source_entity').show();
            } else {
                $('.source_entity').hide();
            }
        });

        /* Toggle autosave of textarea value */
        $("#toggle_autosave").click( function() {
            if ($(this).is(":checked")){
                stringset.unbindSaveButton();
                stringset.bindBlurTextArea();
                stringset.push();
                alert('{% trans "Translation text will be saved automatically."|escapejs %}');
            } else {
                stringset.unbindBlurTextArea();
                stringset.bindSaveButton();
                alert('{% trans "Translation text will no longer be saved automatically."|escapejs %}');
            }
        });

        /* Save at once all the changed translation values */
        $("#save_all_2").click(function(){ stringset.push(); });

        {% get_permission "project_perm.maintain" for request.user and resource.project as "is_maintainer" %}
        {% if is_maintainer or request.user.is_superuser%}
        /* Delete at once all the translations in this page */
        $("#delete_all_2").click(function(){ delete_these(); });
        function delete_these(){
            var to_delete = [];
            for (j=0; j<this_stringset.strings.length; j++) {
                if(this_stringset.strings[j].isTranslated())
                to_delete.push( $("span#sourceid_"+j).text() );
            }
            if(to_delete.length == 0){
                alert('{% trans "There are no translations (to delete) on this page!"|escapejs %}');
            }else if(confirm("{% trans 'This will delete all translations on this page. Are you sure you want to proceed?' %}")){
                {% if resource %}
                var delete_url = '{% url delete_translation project.slug resource.slug target_language.code %}';
                {% else %}
                var delete_url = '{% url delete_translation project.slug target_language.code %}';
                {% endif %}

                $.ajax({
                    url: delete_url,
                    data: JSON.stringify({to_delete: to_delete}),
                    dataType : "text", // "json" is strict and we get 500
                    type: "POST",
                    contentType: "application/json",
                    success: function(){
                        stringset.translated -= to_delete.length;
                        stringset.untranslated += to_delete.length;
                        oTable.fnDraw();
                    }
                });
            }
        }
        {% endif %}

        /* Save all the updated translation and exit Lotte */
        $("#save_and_exit").click(function(){
            $(window).unbind('unload');
            {% if resource_slug %}
                {% url exit_lotte resource.project.slug resource_slug target_language.code as url_exit_lotte %}
            {% else%}
                {% url exit_lotte resource.project.slug target_language.code as url_exit_lotte %}
            {% endif %}

            //Save & exit
            stringset.push(
                false,
                null,
                function(updated){
                    $.ajax({
                        url: "{{ url_exit_lotte }}",
                        data: JSON.stringify({updated:updated}),
                        dataType : "json",
                        type: "POST",
                        contentType: "application/json",
                        success: function(data, textStatus) {
                            if (textStatus=='success'){
                                window.location = data['redirect'];
                            }
                        }
                    });
                });
        });


        /* Wrapper ... to be DRY */
        function traverse_filters(){
            filter_var = "";
            $(".filters").each( function() {
                if ($(this).attr('checked')) {
                    filter_var += $(this).attr('id')+',';
                }
            });
            user_filters_values = "";
            // Parse one by one to reuse the older applied filters
            $(".user_filters").each( function() {
                if ($(this).attr('checked')) {
                    user_filters_values += $(this).attr('id')+',';
                }
            });
            resource_filters_values = "";
            // Parse one by one to reuse the older applied filters
            $(".resource_filters").each( function() {
                if ($(this).attr('checked')) {
                    resource_filters_values += $(this).attr('id')+',';
                }
            });
            more_languages_values = "";
            // Parse one by one to reuse the older applied filters
            $(".more_languages").each( function() {
                if ($(this).attr('checked')) {
                    more_languages_values += $(this).attr('id')+',';
                }
            });
            oTable.fnDraw();
        }

        /* Bind checkbox change event  for translated/untranslated */
        // Just a extra check for IE8 (this will be fixed with jQuery 1.4)
        $(".filters").bind($.browser.msie ? 'propertychange': 'change',
            function(e) {
            if (e.type == "change" || (e.type == "propertychange" &&
                                       window.event.propertyName == "checked")) {
                traverse_filters();
            }
        });

        /* Bind checkbox change event for user filters*/
        // Just a extra check for IE8 (this will be fixed with jQuery 1.4)
        $(".user_filters").bind($.browser.msie ? 'propertychange': 'change',
            function(e) {
            if (e.type == "change" || (e.type == "propertychange" &&
                                       window.event.propertyName == "checked")) {
                traverse_filters();
            }
        });

        /* Bind checkbox change event for resource filters*/
        // Just a extra check for IE8 (this will be fixed with jQuery 1.4)
        $(".resource_filters").bind($.browser.msie ? 'propertychange': 'change',
            function(e) {
            if (e.type == "change" || (e.type == "propertychange" &&
                                       window.event.propertyName == "checked")) {
                traverse_filters();
            }
        });

        /* Bind checkbox change event for more languages*/
        // Just a extra check for IE8 (this will be fixed with jQuery 1.4)
        $(".more_languages").bind($.browser.msie ? 'propertychange': 'change',
            function(e) {
            if (e.type == "change" || (e.type == "propertychange" &&
                                       window.event.propertyName == "checked")) {
                traverse_filters();
            }
        });

        /* Bind menu filters for more languages */
        $('#filtermenu0 .filtermenu-trigger').toggle(function(){
            $('#more_languages_menu').show();
        }, function(){
            $('#more_languages_menu').hide();
        });

        /* Bind menu filters for users */
        $('#filtermenu1 .filtermenu-trigger').toggle(function(){
            $('#filtermenu_users').show();
        }, function(){
            $('#filtermenu_users').hide();
        });

        {% ifnotequal resources|length 1 %}
        /* Bind menu filters for resources */
        $('#filtermenu2 .filtermenu-trigger').toggle(function(){
            $('#filtermenu_resources').show();
        }, function(){
            $('#filtermenu_resources').hide();
        });
        {% endifnotequal %}

        $("#settingspanel a:first").click(function() {
            if($(this).next(".subpanel").is(':visible')){ //If subpanel is already active...
                $(this).next(".subpanel").hide(); //Hide active subpanel
                $("#footpanel li a").removeClass('active'); //Remove active class on the subpanel trigger
            }
            else { //if subpanel is not active...
                $(".subpanel").hide(); //Hide all subpanels
                $(this).next(".subpanel").toggle(); //Toggle the subpanel to make active
                $("#footpanel li a").removeClass('active'); //Remove active class on all subpanel trigger
                $(this).toggleClass('active'); //Toggle the active class on the subpanel trigger
            }
            return false; //Prevent browser jump to link anchor
        });

        //Click event outside of subpanel
        $(document).click(function() { //Click anywhere and...
            $(".subpanel").hide(); //hide subpanel
            $("#footpanel li a").removeClass('active'); //remove active class on subpanel trigger
        });
        $('.subpanel ul').click(function(e) {
            e.stopPropagation(); //Prevents the subpanel ul from closing on click
        });

        // Enable tooltips with tipsy
        $(".tipsy_enable").tipsy({'html':true, 'gravity':'s'});
        $('#review-all').tipsy({'gravity':'s'});

        $(".lotte-header-link").each(function(){
            $(this).appendTo("#stringset_table_wrapper .top").show();
        });
        
        $("a.shortcuts.fancy").facebox({});
    });

</script>

{% hook "tab_lotte.html" function %}

{% endblock %}

{% block title %}
{{ block.super }} |
{{resource}}
{% endblock %}

{% block content_title %}

<h2 class="pagetitle header_idle {% if short_desc %} with_description{% endif %}"><a class="smooth-transition" href="{{ project.get_absolute_url }}">{{ project.name }}</a></h2><h2 class="pagetitle">&nbsp;/&nbsp;</h2><h2 class="header_idle pagetitle with_description"><a class="smooth-transition" href="{{ resource.get_absolute_url }}">{{ resource.name }}</a></h2><h2 class="pagetitle">&nbsp;/&nbsp;{{ target_language }}</h2>

{% endblock %}

{% block body_class %}project_list{% endblock %}

{% block content_header_sec %}
  <div class="lotte-header-link"><a href="#shortcutsdiv" class="i16 nude-button shortcuts fancy tipsy_enable" title="Lotte keyboard shortcuts">{% trans "Shortcuts" %}</a></div>

  {% hook "lotte_header_link.html" %}
    
    <div style="display:none;">
    	<div id="shortcutsdiv" class="facebox-content">
    		<h4>{% trans "Keyboard shortcuts" %}</h4>
    		<div><div class="shortcut-label">Alt-l</div> <div class="shortcut-action">{% trans "Moves to the next translations page." %}</div></div>
    		<div><div class="shortcut-label">Alt-j</div> <div class="shortcut-action">{% trans "Moves to the previous translations page." %}</div></div>
    		<div><div class="shortcut-label">Alt-i</div> <div class="shortcut-action">{% trans "Moves focus one row upwards." %}</div></div>
    		<div><div class="shortcut-label">Alt-k</div> <div class="shortcut-action">{% trans "Moves focus one row downwards." %}</div></div>
    		<div><div class="shortcut-label">Alt-g</div> <div class="shortcut-action">{% trans "Fill in the translation textarea with the content of the source string. (Copy the source string as it is, to the translation area.)" %}</div></div>
    	</div>
    </div>
    
{% endblock %}


{% block content_main %}

{% get_permission "project_perm.maintain" for request.user and resource.project as "is_maintainer" %}
{% get_permission "project_perm.proofread" for request.user and resource.project,target_language as "is_reviewer" %}

<div class="floatright filtermenu-wrapper">

  <div id="filtermenu0" class="filtermenu tipsy_enable" title="{% trans "Show translations in<br /> the selected languages" %}">
    <a class="filtermenu-trigger buttonized" href="#">
    <span class="filtermenu-icon"> </span>
    <span class="filtermenu-title">{% trans "More languages" %}</span>
    </a>
  </div>
  {% include "more_languages.html" %}

  <div id="filtermenu1" class="filtermenu tipsy_enable" title="{% trans "Show only the translations<br /> by the selected users" %}">
    <a class="filtermenu-trigger buttonized" href="#">
    <span class="filtermenu-icon"> </span>
    <span class="filtermenu-title">{% trans "Filter by users" %}</span>
    </a>
  </div>
  {% include "filters_menu_users.html" %}

  {% ifnotequal resources|length 1 %}
  <div id="filtermenu2" class="filtermenu tipsy_enable" title="{% trans "Show only the strings from<br /> the selected resources." %}">
    <a class="filtermenu-trigger buttonized" href="#">
    <span class="filtermenu-icon"> </span>
    <span class="filtermenu-title">{% trans "Filter by resources" %}</span>
    </a>
  </div>
  {% include "filters_menu_resources.html" %}
  {% endifnotequal %}

</div>

<table class="definition stats_totals" id="stats_table">
  <input id="filter_entries" type="hidden" name="filter_entries"/>

  {% with untranslated_strings|add:translated_strings as total_strings %}
  <tr>
    <th class="translated">{% trans "Translated" %}</th>
    <td id="total_translated">{{ translated_strings|intcomma }}</td>
    <td id="total_translated_perc">?</td>
    <td>
      <input id="translated" class="filters" type="checkbox" {% if not untranslated_strings %}checked="checked"{% endif %} name="only_translated"/>
    </td>
  </tr>

  <tr>
    <th class="untranslated">{% trans "Remaining" %}</th>
    <td id="total_untranslated">{{ untranslated_strings|intcomma }}</td>
    <td id="total_untranslated_perc">?</td>
    <td>
      <input id="untranslated" class="filters" type="checkbox" checked="checked" name="only_untranslated"/>
    </td>
  </tr>

  <tr>
    <th class="fuzzy">{% trans "Reviewed" %}</th>
    <td id="total_reviewed">{{ reviewed_strings|intcomma }}</td>
    <td id="total_reviewed_perc">?</td>
    <td>
      <input id="reviewed" class="filters" type="checkbox" name="only_reviewed"/>
    </td>
  </tr>

  <tr class="last">
    <th>{% trans "Total" %}</th>
      <td id="total_sum">{{ total_strings|intcomma }}</td>
  </tr>
  {% endwith %}
</table>



<table id='stringset_table'>
    <thead>
        <tr>
        <th></th>
        <th></th>
        <th>{% trans "Source string" %}</th>
        <th>{% trans "Translation" %}</th>
        <th></th>
        <th>&nbsp;</th>
        {% if is_reviewer %}
        <th>
          <input title="{% trans "Mark all strings as reviewed." %}" id="review-all" type="checkbox" name="review-all"/>
        </th>
        {% endif %}
        </tr>
    </thead>
</table>

<div id="footer_lotte">
    <a id="save_all_2" class="i16 save_all buttonized">{% trans 'Save all' %}</a>

    {% if is_maintainer or request.user.is_superuser %}
    &nbsp;&nbsp;<a id="delete_all_2" class="i16 delete buttonized">{% trans 'Delete translations' %}</a>
    {% endif %}
    &nbsp;&nbsp;<a id="save_and_exit" class="i16 save buttonized">{% trans 'Save and Exit' %}</a>
</div>

<div id="footpanel">
    <ul id="mainpanel">
        <li id="settingspanel">
            <a href="#" class="settings">{% trans "General settings" %}</a>
            <div class="subpanel">
                <ul>
                    <li class="verbose">
                        <input id="toggle_verbose" type="checkbox" />
                        <span>{% trans "Verbose editing" %}</span>
                    </li>
                    <li class="auto_save">
                        <input id="toggle_autosave" type="checkbox" checked="checked"/>
                        <span>{% trans "Auto save" %}</span>
                    </li>
                    <li class="shortcuts">
                        <input id="toggle_shortcuts" type="checkbox" checked="checked"/>
                        <span>{% trans "Enable shortcuts" %}</span>
                    </li>
                    <li class="auto_open_suggestions">
                        <input id="toggle_autosuggestions" type="checkbox" />
                        <span>{% trans "Enable suggestions auto-open" %}</span>
                    </li>
                </ul>
            </div>
        </li>
    </ul>
</div>

{% endblock %}

{% block livesupport %}{% endblock %}

{% block content_footer %}{% endblock %}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.