Project

General

Profile

« Previous | Next » 

Revision 73f2fc18

Added by Marc Dequènes over 10 years ago

  • ID 73f2fc180533c37c7205b21422e8452fe44295b9

[evol] language can be forced in the user admin page (closes #6) (no user interface yet)

View differences:

app/controllers/admin/users_controller.rb
2 2
  simple_rest_support
3 3

  
4 4
  before_filter :admin_required
5
  after_filter :set_language, :only => [:update]
6

  
7
  def set_language
8
    @config.switch_locale(@user.prefered_language) if @user == @current_user
9
  end
5 10
end
app/controllers/application.rb
22 22

  
23 23
  init_gettext MyCyma::Info::app_name
24 24

  
25
  before_init_gettext :ensure_prefered_language
26

  
25 27
  def initialize
26 28
    super
27 29

  
......
62 64
      redirect_to :controller => 'welcome', :action => 'index'
63 65
    end
64 66
  end
67

  
68
  def ensure_prefered_language
69
    @config.switch_locale(current_user.prefered_language) if current_user
70
  end
65 71
end
app/views/admin/users/_form.rhtml
1 1
<p>
2 2
<%
3
selected_artwork_set_id = (@artwork ? @artwork.artwork_set_id : nil)
4
selected_artwork_group_id = (@artwork ? @artwork.artwork_group_id : nil)
5
selected_artwork_size_id = (@artwork ? @artwork.artwork_size_id : nil)
3
language_list = @config.available_languages.collect{|id, name| [name, id] }
6 4

  
7 5
form_for_resource do |f|
8 6
%>
......
11 9
  table.field :login, _("Login"), :text_field
12 10
  table.field :real_name, _("Real Name"), :text_field
13 11
  table.field :email, _("eMail"), :text_field
12
  table.field :prefered_language, _("Prefered language"), :select, language_list
14 13
  table.field :admin, _("Administrator?"), :check_box
15 14
  table.field :password, _("Password"), :password_field
16 15
  table.field :password_confirmation, _("Password (confirmation)"), :password_field
app/views/admin/users/show.rhtml
6 6
  table.content [_("Login:"), @user.login]
7 7
  table.content [_("Real Name:"), @user.real_name]
8 8
  table.content [_("Email:"), @user.email]
9
  table.content [_("Prefered language:"), @user.prefered_langage]
9 10
  table.content [_("Administrator?"), display_boolean(@user.admin)]
10 11
  table.category _("Entry Status") do |cat|
11 12
    cat.content [_("First Created:"), "#{display_timestamp(@user.created_at)}"]
lib/mycyma.rb
3 3

  
4 4
require 'ostruct'
5 5
require 'singleton'
6
require 'gettext'
6 7

  
7 8
module MyCyma
8 9

  
9 10
  class Config < OpenStruct
10 11
    include Singleton
12
    include GetText
11 13

  
12 14
    def initialize
13 15
      str = File.read(File.join(RAILS_ROOT, "config", "settings.yml"))
......
24 26
      list
25 27
    end
26 28

  
27
  end
29
    # should be guessed
30
    def available_languages
31
      {
32
        ''      => _("Browser preference"),
33
        'en'    => _("English"),
34
        'fr'    => _("French")
35
      }
36
    end
28 37

  
38
    def switch_locale(locale = nil)
39
      # if unspecified, use browser prefered langage
40
      if locale.nil?
41
        cgi = nil
42
        if defined? request.cgi
43
          cgi = request.cgi
44
        end
45
        set_cgi(cgi)
46
      else
47
        set_locale(locale)
48
      end
49
    end
50
  end
29 51
end
30 52

  
po/MyCyma.pot
7 7
msgid ""
8 8
msgstr ""
9 9
"Project-Id-Version: MyCyma 0.1.0\n"
10
"POT-Creation-Date: 2009-03-18 14:26+0100\n"
10
"POT-Creation-Date: 2009-03-24 01:14+0100\n"
11 11
"PO-Revision-Date: 2008-07-28 02:17+0200\n"
12 12
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 13
"Language-Team: LANGUAGE <LL@li.org>\n"
......
168 168
msgid "User|Admin"
169 169
msgstr ""
170 170

  
171
#: app/models/user.rb:-
172
msgid "User|Prefered language"
173
msgstr ""
174

  
171 175
#: app/models/user.rb:11
172 176
msgid "Invalid email"
173 177
msgstr ""
......
352 356
msgid "Updated at:"
353 357
msgstr ""
354 358

  
355
#: app/controllers/application.rb:39
359
#: app/controllers/application.rb:42
356 360
msgid "Please login to continue"
357 361
msgstr ""
358 362

  
......
520 524
msgstr ""
521 525

  
522 526
#: app/views/admin/artwork_step_images/show.rhtml:27
523
#: app/views/admin/artworks/show.rhtml:42
527
#: app/views/admin/artworks/show.rhtml:44
524 528
msgid "Entry First Created:"
525 529
msgstr ""
526 530

  
527 531
#: app/views/admin/artwork_step_images/show.rhtml:28
528
#: app/views/admin/artworks/show.rhtml:43
532
#: app/views/admin/artworks/show.rhtml:45
529 533
msgid "Entry Last Updated:"
530 534
msgstr ""
531 535

  
......
534 538
msgstr ""
535 539

  
536 540
#: app/views/admin/artwork_step_images/_form.rhtml:7
537
#: app/views/admin/artworks/show.rhtml:37
541
#: app/views/admin/artworks/show.rhtml:39
538 542
#: app/views/admin/artworks/_form.rhtml:37
539 543
msgid "Date:"
540 544
msgstr ""
......
555 559
msgid "List of users"
556 560
msgstr ""
557 561

  
558
#: app/views/admin/users/index.rhtml:6 app/views/admin/users/_form.rhtml:11
562
#: app/views/admin/users/index.rhtml:6 app/views/admin/users/_form.rhtml:9
559 563
msgid "Login"
560 564
msgstr ""
561 565

  
562
#: app/views/admin/users/index.rhtml:7 app/views/admin/users/_form.rhtml:12
566
#: app/views/admin/users/index.rhtml:7 app/views/admin/users/_form.rhtml:10
563 567
msgid "Real Name"
564 568
msgstr ""
565 569

  
566
#: app/views/admin/users/index.rhtml:8 app/views/admin/users/_form.rhtml:13
570
#: app/views/admin/users/index.rhtml:8 app/views/admin/users/_form.rhtml:11
567 571
msgid "eMail"
568 572
msgstr ""
569 573

  
......
583 587
msgid "Email:"
584 588
msgstr ""
585 589

  
586
#: app/views/admin/users/show.rhtml:9 app/views/admin/users/_form.rhtml:14
590
#: app/views/admin/users/show.rhtml:9
591
msgid "Prefered language:"
592
msgstr ""
593

  
594
#: app/views/admin/users/show.rhtml:10 app/views/admin/users/_form.rhtml:13
587 595
msgid "Administrator?"
588 596
msgstr ""
589 597

  
590
#: app/views/admin/users/show.rhtml:10
598
#: app/views/admin/users/show.rhtml:11
591 599
msgid "Entry Status"
592 600
msgstr ""
593 601

  
594
#: app/views/admin/users/show.rhtml:11
602
#: app/views/admin/users/show.rhtml:12
595 603
msgid "First Created:"
596 604
msgstr ""
597 605

  
598
#: app/views/admin/users/show.rhtml:12
606
#: app/views/admin/users/show.rhtml:13
599 607
msgid "Last Updated:"
600 608
msgstr ""
601 609

  
602
#: app/views/admin/users/show.rhtml:18
610
#: app/views/admin/users/show.rhtml:19
603 611
msgid "Display all users"
604 612
msgstr ""
605 613

  
606
#: app/views/admin/users/_form.rhtml:15
614
#: app/views/admin/users/_form.rhtml:12
615
msgid "Prefered language"
616
msgstr ""
617

  
618
#: app/views/admin/users/_form.rhtml:14
607 619
msgid "Password"
608 620
msgstr ""
609 621

  
610
#: app/views/admin/users/_form.rhtml:16
622
#: app/views/admin/users/_form.rhtml:15
611 623
msgid "Password (confirmation)"
612 624
msgstr ""
613 625

  
......
746 758
msgstr ""
747 759

  
748 760
#: app/views/admin/artwork_sets/show.rhtml:13
749
#: app/views/admin/artworks/show.rhtml:50
761
#: app/views/admin/artworks/show.rhtml:52
750 762
msgid "Display all sets"
751 763
msgstr ""
752 764

  
......
831 843
msgstr ""
832 844

  
833 845
#: app/views/admin/artworks/index.rhtml:24
834
#: app/views/admin/artworks/show.rhtml:49
846
#: app/views/admin/artworks/show.rhtml:51
835 847
msgid "View Steps"
836 848
msgstr ""
837 849

  
......
839 851
msgid "Artwork '%s'"
840 852
msgstr ""
841 853

  
842
#: app/views/admin/artworks/show.rhtml:12
854
#: app/views/admin/artworks/show.rhtml:14
843 855
#: app/views/admin/artworks/_form.rhtml:11
844 856
msgid "General"
845 857
msgstr ""
846 858

  
847
#: app/views/admin/artworks/show.rhtml:27
859
#: app/views/admin/artworks/show.rhtml:29
848 860
msgid "Set / Group:"
849 861
msgstr ""
850 862

  
851
#: app/views/admin/artworks/show.rhtml:28
863
#: app/views/admin/artworks/show.rhtml:30
852 864
#: app/views/admin/artworks/_form.rhtml:26
853 865
msgid "Size:"
854 866
msgstr ""
855 867

  
856
#: app/views/admin/artworks/show.rhtml:29
868
#: app/views/admin/artworks/show.rhtml:31
857 869
#: app/views/admin/artworks/_form.rhtml:28
858 870
msgid "Materials:"
859 871
msgstr ""
860 872

  
861
#: app/views/admin/artworks/show.rhtml:30
873
#: app/views/admin/artworks/show.rhtml:32
862 874
msgid "Supports:"
863 875
msgstr ""
864 876

  
865
#: app/views/admin/artworks/show.rhtml:32
877
#: app/views/admin/artworks/show.rhtml:34
866 878
#: app/views/admin/artworks/_form.rhtml:31
867 879
msgid "Result"
868 880
msgstr ""
869 881

  
870
#: app/views/admin/artworks/show.rhtml:33
882
#: app/views/admin/artworks/show.rhtml:35
871 883
#: app/views/admin/artworks/_form.rhtml:32
872 884
msgid "Condition:"
873 885
msgstr ""
874 886

  
875
#: app/views/admin/artworks/show.rhtml:34
887
#: app/views/admin/artworks/show.rhtml:36
876 888
#: app/views/admin/artworks/_form.rhtml:33
877 889
msgid "Placement"
878 890
msgstr ""
879 891

  
880
#: app/views/admin/artworks/show.rhtml:35
892
#: app/views/admin/artworks/show.rhtml:37
881 893
#: app/views/admin/artworks/_form.rhtml:34
882 894
msgid "Reason:"
883 895
msgstr ""
884 896

  
885
#: app/views/admin/artworks/show.rhtml:36
897
#: app/views/admin/artworks/show.rhtml:38
886 898
#: app/views/admin/artworks/_form.rhtml:36
887 899
msgid "Location:"
888 900
msgstr ""
889 901

  
890
#: app/views/admin/artworks/show.rhtml:40
902
#: app/views/admin/artworks/show.rhtml:42
891 903
msgid "Artwork Status"
892 904
msgstr ""
893 905

  
894
#: app/views/admin/artworks/show.rhtml:49
906
#: app/views/admin/artworks/show.rhtml:51
895 907
msgid "View all Steps"
896 908
msgstr ""
897 909

  
......
946 958
#: app/views/admin/artwork_groups/edit.rhtml:1
947 959
msgid "Modify Artwork Group"
948 960
msgstr ""
961

  
962
#: lib/mycyma.rb:32
963
msgid "Browser preference"
964
msgstr ""
965

  
966
#: lib/mycyma.rb:33
967
msgid "English"
968
msgstr ""
969

  
970
#: lib/mycyma.rb:34
971
msgid "French"
972
msgstr ""
po/fr/MyCyma.po
7 7
msgid ""
8 8
msgstr ""
9 9
"Project-Id-Version: MyCyma 0.1.0\n"
10
"POT-Creation-Date: 2009-03-18 14:26+0100\n"
10
"POT-Creation-Date: 2009-03-24 01:14+0100\n"
11 11
"PO-Revision-Date: 2008-07-28 02:17+0200\n"
12 12
"Last-Translator: Marc Dequènes (Duck) <Duck@DuckCorp.org>\n"
13 13
"MIME-Version: 1.0\n"
......
167 167
msgid "User|Admin"
168 168
msgstr "Utilisateur|Admin"
169 169

  
170
#: app/models/user.rb:-
171
msgid "User|Prefered language"
172
msgstr "Utilisateur|Langage préféré"
173

  
170 174
#: app/models/user.rb:11
171 175
msgid "Invalid email"
172 176
msgstr "Email invalide"
......
351 355
msgid "Updated at:"
352 356
msgstr "Mis(e) à jour le :"
353 357

  
354
#: app/controllers/application.rb:39
358
#: app/controllers/application.rb:42
355 359
msgid "Please login to continue"
356 360
msgstr "Veuillez vous identifier pour continuer"
357 361

  
......
522 526
msgstr "État de l'Étape"
523 527

  
524 528
#: app/views/admin/artwork_step_images/show.rhtml:27
525
#: app/views/admin/artworks/show.rhtml:42
529
#: app/views/admin/artworks/show.rhtml:44
526 530
msgid "Entry First Created:"
527 531
msgstr "Entrée Initialement Créée :"
528 532

  
529 533
#: app/views/admin/artwork_step_images/show.rhtml:28
530
#: app/views/admin/artworks/show.rhtml:43
534
#: app/views/admin/artworks/show.rhtml:45
531 535
msgid "Entry Last Updated:"
532 536
msgstr "Entrée Dernièrement Mise à jour :"
533 537

  
......
536 540
msgstr "Afficher toutes les étapes"
537 541

  
538 542
#: app/views/admin/artwork_step_images/_form.rhtml:7
539
#: app/views/admin/artworks/show.rhtml:37
543
#: app/views/admin/artworks/show.rhtml:39
540 544
#: app/views/admin/artworks/_form.rhtml:37
541 545
msgid "Date:"
542 546
msgstr "Date "
......
557 561
msgid "List of users"
558 562
msgstr "Liste des utilisateurs"
559 563

  
560
#: app/views/admin/users/index.rhtml:6 app/views/admin/users/_form.rhtml:11
564
#: app/views/admin/users/index.rhtml:6 app/views/admin/users/_form.rhtml:9
561 565
msgid "Login"
562 566
msgstr "Identifiant"
563 567

  
564
#: app/views/admin/users/index.rhtml:7 app/views/admin/users/_form.rhtml:12
568
#: app/views/admin/users/index.rhtml:7 app/views/admin/users/_form.rhtml:10
565 569
msgid "Real Name"
566 570
msgstr "Nom"
567 571

  
568
#: app/views/admin/users/index.rhtml:8 app/views/admin/users/_form.rhtml:13
572
#: app/views/admin/users/index.rhtml:8 app/views/admin/users/_form.rhtml:11
569 573
msgid "eMail"
570 574
msgstr "eMail"
571 575

  
......
585 589
msgid "Email:"
586 590
msgstr "Email :"
587 591

  
588
#: app/views/admin/users/show.rhtml:9 app/views/admin/users/_form.rhtml:14
592
#: app/views/admin/users/show.rhtml:9
593
#, fuzzy
594
msgid "Prefered language:"
595
msgstr "Utilisateur|Langage préféré"
596

  
597
#: app/views/admin/users/show.rhtml:10 app/views/admin/users/_form.rhtml:13
589 598
msgid "Administrator?"
590 599
msgstr "Administrateur ?"
591 600

  
592
#: app/views/admin/users/show.rhtml:10
601
#: app/views/admin/users/show.rhtml:11
593 602
msgid "Entry Status"
594 603
msgstr "État de l'entrée"
595 604

  
596
#: app/views/admin/users/show.rhtml:11
605
#: app/views/admin/users/show.rhtml:12
597 606
msgid "First Created:"
598 607
msgstr "Entrée Initialement Créée :"
599 608

  
600
#: app/views/admin/users/show.rhtml:12
609
#: app/views/admin/users/show.rhtml:13
601 610
msgid "Last Updated:"
602 611
msgstr "Entrée Dernièrement Mise à jour :"
603 612

  
604
#: app/views/admin/users/show.rhtml:18
613
#: app/views/admin/users/show.rhtml:19
605 614
msgid "Display all users"
606 615
msgstr "Afficher tous les utilisateurs"
607 616

  
608
#: app/views/admin/users/_form.rhtml:15
617
#: app/views/admin/users/_form.rhtml:12
618
msgid "Prefered language"
619
msgstr "Langage préféré"
620

  
621
#: app/views/admin/users/_form.rhtml:14
609 622
msgid "Password"
610 623
msgstr "Mot de passe"
611 624

  
612
#: app/views/admin/users/_form.rhtml:16
625
#: app/views/admin/users/_form.rhtml:15
613 626
msgid "Password (confirmation)"
614 627
msgstr "Mot de passe (confirmation)"
615 628

  
......
748 761
msgstr "Série n°%u"
749 762

  
750 763
#: app/views/admin/artwork_sets/show.rhtml:13
751
#: app/views/admin/artworks/show.rhtml:50
764
#: app/views/admin/artworks/show.rhtml:52
752 765
msgid "Display all sets"
753 766
msgstr "Afficher toutes les Séries"
754 767

  
......
833 846
msgstr "Étapes"
834 847

  
835 848
#: app/views/admin/artworks/index.rhtml:24
836
#: app/views/admin/artworks/show.rhtml:49
849
#: app/views/admin/artworks/show.rhtml:51
837 850
msgid "View Steps"
838 851
msgstr "Voir les Étapes"
839 852

  
......
841 854
msgid "Artwork '%s'"
842 855
msgstr "Œuvre '%s'"
843 856

  
844
#: app/views/admin/artworks/show.rhtml:12
857
#: app/views/admin/artworks/show.rhtml:14
845 858
#: app/views/admin/artworks/_form.rhtml:11
846 859
msgid "General"
847 860
msgstr "Général"
848 861

  
849
#: app/views/admin/artworks/show.rhtml:27
862
#: app/views/admin/artworks/show.rhtml:29
850 863
msgid "Set / Group:"
851 864
msgstr "Série / Ensemble :"
852 865

  
853
#: app/views/admin/artworks/show.rhtml:28
866
#: app/views/admin/artworks/show.rhtml:30
854 867
#: app/views/admin/artworks/_form.rhtml:26
855 868
msgid "Size:"
856 869
msgstr "Dimensions :"
857 870

  
858
#: app/views/admin/artworks/show.rhtml:29
871
#: app/views/admin/artworks/show.rhtml:31
859 872
#: app/views/admin/artworks/_form.rhtml:28
860 873
msgid "Materials:"
861 874
msgstr "Matériaux :"
862 875

  
863
#: app/views/admin/artworks/show.rhtml:30
876
#: app/views/admin/artworks/show.rhtml:32
864 877
msgid "Supports:"
865 878
msgstr "Supports :"
866 879

  
867
#: app/views/admin/artworks/show.rhtml:32
880
#: app/views/admin/artworks/show.rhtml:34
868 881
#: app/views/admin/artworks/_form.rhtml:31
869 882
msgid "Result"
870 883
msgstr "Résultat"
871 884

  
872
#: app/views/admin/artworks/show.rhtml:33
885
#: app/views/admin/artworks/show.rhtml:35
873 886
#: app/views/admin/artworks/_form.rhtml:32
874 887
msgid "Condition:"
875 888
msgstr "État :"
876 889

  
877
#: app/views/admin/artworks/show.rhtml:34
890
#: app/views/admin/artworks/show.rhtml:36
878 891
#: app/views/admin/artworks/_form.rhtml:33
879 892
msgid "Placement"
880 893
msgstr "Placement"
881 894

  
882
#: app/views/admin/artworks/show.rhtml:35
895
#: app/views/admin/artworks/show.rhtml:37
883 896
#: app/views/admin/artworks/_form.rhtml:34
884 897
msgid "Reason:"
885 898
msgstr "Raison :"
886 899

  
887
#: app/views/admin/artworks/show.rhtml:36
900
#: app/views/admin/artworks/show.rhtml:38
888 901
#: app/views/admin/artworks/_form.rhtml:36
889 902
msgid "Location:"
890 903
msgstr "Lieu :"
891 904

  
892
#: app/views/admin/artworks/show.rhtml:40
905
#: app/views/admin/artworks/show.rhtml:42
893 906
msgid "Artwork Status"
894 907
msgstr "État de l'Œuvre"
895 908

  
896
#: app/views/admin/artworks/show.rhtml:49
909
#: app/views/admin/artworks/show.rhtml:51
897 910
msgid "View all Steps"
898 911
msgstr "Voir toutes les Étapes"
899 912

  
......
949 962
msgid "Modify Artwork Group"
950 963
msgstr "Modifier l'Ensemble"
951 964

  
965
#: lib/mycyma.rb:32
966
msgid "Browser preference"
967
msgstr "Préférence du navigateur"
968

  
969
#: lib/mycyma.rb:33
970
msgid "English"
971
msgstr "Anglais"
972

  
973
#: lib/mycyma.rb:34
974
msgid "French"
975
msgstr "Français"

Also available in: Unified diff