Project

General

Profile

« Previous | Next » 

Revision 73f2fc18

Added by Marc Dequènes over 15 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
simple_rest_support
before_filter :admin_required
after_filter :set_language, :only => [:update]
def set_language
@config.switch_locale(@user.prefered_language) if @user == @current_user
end
end
app/controllers/application.rb
init_gettext MyCyma::Info::app_name
before_init_gettext :ensure_prefered_language
def initialize
super
......
redirect_to :controller => 'welcome', :action => 'index'
end
end
def ensure_prefered_language
@config.switch_locale(current_user.prefered_language) if current_user
end
end
app/views/admin/users/_form.rhtml
<p>
<%
selected_artwork_set_id = (@artwork ? @artwork.artwork_set_id : nil)
selected_artwork_group_id = (@artwork ? @artwork.artwork_group_id : nil)
selected_artwork_size_id = (@artwork ? @artwork.artwork_size_id : nil)
language_list = @config.available_languages.collect{|id, name| [name, id] }
form_for_resource do |f|
%>
......
table.field :login, _("Login"), :text_field
table.field :real_name, _("Real Name"), :text_field
table.field :email, _("eMail"), :text_field
table.field :prefered_language, _("Prefered language"), :select, language_list
table.field :admin, _("Administrator?"), :check_box
table.field :password, _("Password"), :password_field
table.field :password_confirmation, _("Password (confirmation)"), :password_field
app/views/admin/users/show.rhtml
table.content [_("Login:"), @user.login]
table.content [_("Real Name:"), @user.real_name]
table.content [_("Email:"), @user.email]
table.content [_("Prefered language:"), @user.prefered_langage]
table.content [_("Administrator?"), display_boolean(@user.admin)]
table.category _("Entry Status") do |cat|
cat.content [_("First Created:"), "#{display_timestamp(@user.created_at)}"]
lib/mycyma.rb
require 'ostruct'
require 'singleton'
require 'gettext'
module MyCyma
class Config < OpenStruct
include Singleton
include GetText
def initialize
str = File.read(File.join(RAILS_ROOT, "config", "settings.yml"))
......
list
end
end
# should be guessed
def available_languages
{
'' => _("Browser preference"),
'en' => _("English"),
'fr' => _("French")
}
end
def switch_locale(locale = nil)
# if unspecified, use browser prefered langage
if locale.nil?
cgi = nil
if defined? request.cgi
cgi = request.cgi
end
set_cgi(cgi)
else
set_locale(locale)
end
end
end
end
po/MyCyma.pot
msgid ""
msgstr ""
"Project-Id-Version: MyCyma 0.1.0\n"
"POT-Creation-Date: 2009-03-18 14:26+0100\n"
"POT-Creation-Date: 2009-03-24 01:14+0100\n"
"PO-Revision-Date: 2008-07-28 02:17+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
msgid "User|Admin"
msgstr ""
#: app/models/user.rb:-
msgid "User|Prefered language"
msgstr ""
#: app/models/user.rb:11
msgid "Invalid email"
msgstr ""
......
msgid "Updated at:"
msgstr ""
#: app/controllers/application.rb:39
#: app/controllers/application.rb:42
msgid "Please login to continue"
msgstr ""
......
msgstr ""
#: app/views/admin/artwork_step_images/show.rhtml:27
#: app/views/admin/artworks/show.rhtml:42
#: app/views/admin/artworks/show.rhtml:44
msgid "Entry First Created:"
msgstr ""
#: app/views/admin/artwork_step_images/show.rhtml:28
#: app/views/admin/artworks/show.rhtml:43
#: app/views/admin/artworks/show.rhtml:45
msgid "Entry Last Updated:"
msgstr ""
......
msgstr ""
#: app/views/admin/artwork_step_images/_form.rhtml:7
#: app/views/admin/artworks/show.rhtml:37
#: app/views/admin/artworks/show.rhtml:39
#: app/views/admin/artworks/_form.rhtml:37
msgid "Date:"
msgstr ""
......
msgid "List of users"
msgstr ""
#: app/views/admin/users/index.rhtml:6 app/views/admin/users/_form.rhtml:11
#: app/views/admin/users/index.rhtml:6 app/views/admin/users/_form.rhtml:9
msgid "Login"
msgstr ""
#: app/views/admin/users/index.rhtml:7 app/views/admin/users/_form.rhtml:12
#: app/views/admin/users/index.rhtml:7 app/views/admin/users/_form.rhtml:10
msgid "Real Name"
msgstr ""
#: app/views/admin/users/index.rhtml:8 app/views/admin/users/_form.rhtml:13
#: app/views/admin/users/index.rhtml:8 app/views/admin/users/_form.rhtml:11
msgid "eMail"
msgstr ""
......
msgid "Email:"
msgstr ""
#: app/views/admin/users/show.rhtml:9 app/views/admin/users/_form.rhtml:14
#: app/views/admin/users/show.rhtml:9
msgid "Prefered language:"
msgstr ""
#: app/views/admin/users/show.rhtml:10 app/views/admin/users/_form.rhtml:13
msgid "Administrator?"
msgstr ""
#: app/views/admin/users/show.rhtml:10
#: app/views/admin/users/show.rhtml:11
msgid "Entry Status"
msgstr ""
#: app/views/admin/users/show.rhtml:11
#: app/views/admin/users/show.rhtml:12
msgid "First Created:"
msgstr ""
#: app/views/admin/users/show.rhtml:12
#: app/views/admin/users/show.rhtml:13
msgid "Last Updated:"
msgstr ""
#: app/views/admin/users/show.rhtml:18
#: app/views/admin/users/show.rhtml:19
msgid "Display all users"
msgstr ""
#: app/views/admin/users/_form.rhtml:15
#: app/views/admin/users/_form.rhtml:12
msgid "Prefered language"
msgstr ""
#: app/views/admin/users/_form.rhtml:14
msgid "Password"
msgstr ""
#: app/views/admin/users/_form.rhtml:16
#: app/views/admin/users/_form.rhtml:15
msgid "Password (confirmation)"
msgstr ""
......
msgstr ""
#: app/views/admin/artwork_sets/show.rhtml:13
#: app/views/admin/artworks/show.rhtml:50
#: app/views/admin/artworks/show.rhtml:52
msgid "Display all sets"
msgstr ""
......
msgstr ""
#: app/views/admin/artworks/index.rhtml:24
#: app/views/admin/artworks/show.rhtml:49
#: app/views/admin/artworks/show.rhtml:51
msgid "View Steps"
msgstr ""
......
msgid "Artwork '%s'"
msgstr ""
#: app/views/admin/artworks/show.rhtml:12
#: app/views/admin/artworks/show.rhtml:14
#: app/views/admin/artworks/_form.rhtml:11
msgid "General"
msgstr ""
#: app/views/admin/artworks/show.rhtml:27
#: app/views/admin/artworks/show.rhtml:29
msgid "Set / Group:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:28
#: app/views/admin/artworks/show.rhtml:30
#: app/views/admin/artworks/_form.rhtml:26
msgid "Size:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:29
#: app/views/admin/artworks/show.rhtml:31
#: app/views/admin/artworks/_form.rhtml:28
msgid "Materials:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:30
#: app/views/admin/artworks/show.rhtml:32
msgid "Supports:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:32
#: app/views/admin/artworks/show.rhtml:34
#: app/views/admin/artworks/_form.rhtml:31
msgid "Result"
msgstr ""
#: app/views/admin/artworks/show.rhtml:33
#: app/views/admin/artworks/show.rhtml:35
#: app/views/admin/artworks/_form.rhtml:32
msgid "Condition:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:34
#: app/views/admin/artworks/show.rhtml:36
#: app/views/admin/artworks/_form.rhtml:33
msgid "Placement"
msgstr ""
#: app/views/admin/artworks/show.rhtml:35
#: app/views/admin/artworks/show.rhtml:37
#: app/views/admin/artworks/_form.rhtml:34
msgid "Reason:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:36
#: app/views/admin/artworks/show.rhtml:38
#: app/views/admin/artworks/_form.rhtml:36
msgid "Location:"
msgstr ""
#: app/views/admin/artworks/show.rhtml:40
#: app/views/admin/artworks/show.rhtml:42
msgid "Artwork Status"
msgstr ""
#: app/views/admin/artworks/show.rhtml:49
#: app/views/admin/artworks/show.rhtml:51
msgid "View all Steps"
msgstr ""
......
#: app/views/admin/artwork_groups/edit.rhtml:1
msgid "Modify Artwork Group"
msgstr ""
#: lib/mycyma.rb:32
msgid "Browser preference"
msgstr ""
#: lib/mycyma.rb:33
msgid "English"
msgstr ""
#: lib/mycyma.rb:34
msgid "French"
msgstr ""
po/fr/MyCyma.po
msgid ""
msgstr ""
"Project-Id-Version: MyCyma 0.1.0\n"
"POT-Creation-Date: 2009-03-18 14:26+0100\n"
"POT-Creation-Date: 2009-03-24 01:14+0100\n"
"PO-Revision-Date: 2008-07-28 02:17+0200\n"
"Last-Translator: Marc Dequènes (Duck) <Duck@DuckCorp.org>\n"
"MIME-Version: 1.0\n"
......
msgid "User|Admin"
msgstr "Utilisateur|Admin"
#: app/models/user.rb:-
msgid "User|Prefered language"
msgstr "Utilisateur|Langage préféré"
#: app/models/user.rb:11
msgid "Invalid email"
msgstr "Email invalide"
......
msgid "Updated at:"
msgstr "Mis(e) à jour le :"
#: app/controllers/application.rb:39
#: app/controllers/application.rb:42
msgid "Please login to continue"
msgstr "Veuillez vous identifier pour continuer"
......
msgstr "État de l'Étape"
#: app/views/admin/artwork_step_images/show.rhtml:27
#: app/views/admin/artworks/show.rhtml:42
#: app/views/admin/artworks/show.rhtml:44
msgid "Entry First Created:"
msgstr "Entrée Initialement Créée :"
#: app/views/admin/artwork_step_images/show.rhtml:28
#: app/views/admin/artworks/show.rhtml:43
#: app/views/admin/artworks/show.rhtml:45
msgid "Entry Last Updated:"
msgstr "Entrée Dernièrement Mise à jour :"
......
msgstr "Afficher toutes les étapes"
#: app/views/admin/artwork_step_images/_form.rhtml:7
#: app/views/admin/artworks/show.rhtml:37
#: app/views/admin/artworks/show.rhtml:39
#: app/views/admin/artworks/_form.rhtml:37
msgid "Date:"
msgstr "Date "
......
msgid "List of users"
msgstr "Liste des utilisateurs"
#: app/views/admin/users/index.rhtml:6 app/views/admin/users/_form.rhtml:11
#: app/views/admin/users/index.rhtml:6 app/views/admin/users/_form.rhtml:9
msgid "Login"
msgstr "Identifiant"
#: app/views/admin/users/index.rhtml:7 app/views/admin/users/_form.rhtml:12
#: app/views/admin/users/index.rhtml:7 app/views/admin/users/_form.rhtml:10
msgid "Real Name"
msgstr "Nom"
#: app/views/admin/users/index.rhtml:8 app/views/admin/users/_form.rhtml:13
#: app/views/admin/users/index.rhtml:8 app/views/admin/users/_form.rhtml:11
msgid "eMail"
msgstr "eMail"
......
msgid "Email:"
msgstr "Email :"
#: app/views/admin/users/show.rhtml:9 app/views/admin/users/_form.rhtml:14
#: app/views/admin/users/show.rhtml:9
#, fuzzy
msgid "Prefered language:"
msgstr "Utilisateur|Langage préféré"
#: app/views/admin/users/show.rhtml:10 app/views/admin/users/_form.rhtml:13
msgid "Administrator?"
msgstr "Administrateur ?"
#: app/views/admin/users/show.rhtml:10
#: app/views/admin/users/show.rhtml:11
msgid "Entry Status"
msgstr "État de l'entrée"
#: app/views/admin/users/show.rhtml:11
#: app/views/admin/users/show.rhtml:12
msgid "First Created:"
msgstr "Entrée Initialement Créée :"
#: app/views/admin/users/show.rhtml:12
#: app/views/admin/users/show.rhtml:13
msgid "Last Updated:"
msgstr "Entrée Dernièrement Mise à jour :"
#: app/views/admin/users/show.rhtml:18
#: app/views/admin/users/show.rhtml:19
msgid "Display all users"
msgstr "Afficher tous les utilisateurs"
#: app/views/admin/users/_form.rhtml:15
#: app/views/admin/users/_form.rhtml:12
msgid "Prefered language"
msgstr "Langage préféré"
#: app/views/admin/users/_form.rhtml:14
msgid "Password"
msgstr "Mot de passe"
#: app/views/admin/users/_form.rhtml:16
#: app/views/admin/users/_form.rhtml:15
msgid "Password (confirmation)"
msgstr "Mot de passe (confirmation)"
......
msgstr "Série n°%u"
#: app/views/admin/artwork_sets/show.rhtml:13
#: app/views/admin/artworks/show.rhtml:50
#: app/views/admin/artworks/show.rhtml:52
msgid "Display all sets"
msgstr "Afficher toutes les Séries"
......
msgstr "Étapes"
#: app/views/admin/artworks/index.rhtml:24
#: app/views/admin/artworks/show.rhtml:49
#: app/views/admin/artworks/show.rhtml:51
msgid "View Steps"
msgstr "Voir les Étapes"
......
msgid "Artwork '%s'"
msgstr "Œuvre '%s'"
#: app/views/admin/artworks/show.rhtml:12
#: app/views/admin/artworks/show.rhtml:14
#: app/views/admin/artworks/_form.rhtml:11
msgid "General"
msgstr "Général"
#: app/views/admin/artworks/show.rhtml:27
#: app/views/admin/artworks/show.rhtml:29
msgid "Set / Group:"
msgstr "Série / Ensemble :"
#: app/views/admin/artworks/show.rhtml:28
#: app/views/admin/artworks/show.rhtml:30
#: app/views/admin/artworks/_form.rhtml:26
msgid "Size:"
msgstr "Dimensions :"
#: app/views/admin/artworks/show.rhtml:29
#: app/views/admin/artworks/show.rhtml:31
#: app/views/admin/artworks/_form.rhtml:28
msgid "Materials:"
msgstr "Matériaux :"
#: app/views/admin/artworks/show.rhtml:30
#: app/views/admin/artworks/show.rhtml:32
msgid "Supports:"
msgstr "Supports :"
#: app/views/admin/artworks/show.rhtml:32
#: app/views/admin/artworks/show.rhtml:34
#: app/views/admin/artworks/_form.rhtml:31
msgid "Result"
msgstr "Résultat"
#: app/views/admin/artworks/show.rhtml:33
#: app/views/admin/artworks/show.rhtml:35
#: app/views/admin/artworks/_form.rhtml:32
msgid "Condition:"
msgstr "État :"
#: app/views/admin/artworks/show.rhtml:34
#: app/views/admin/artworks/show.rhtml:36
#: app/views/admin/artworks/_form.rhtml:33
msgid "Placement"
msgstr "Placement"
#: app/views/admin/artworks/show.rhtml:35
#: app/views/admin/artworks/show.rhtml:37
#: app/views/admin/artworks/_form.rhtml:34
msgid "Reason:"
msgstr "Raison :"
#: app/views/admin/artworks/show.rhtml:36
#: app/views/admin/artworks/show.rhtml:38
#: app/views/admin/artworks/_form.rhtml:36
msgid "Location:"
msgstr "Lieu :"
#: app/views/admin/artworks/show.rhtml:40
#: app/views/admin/artworks/show.rhtml:42
msgid "Artwork Status"
msgstr "État de l'Œuvre"
#: app/views/admin/artworks/show.rhtml:49
#: app/views/admin/artworks/show.rhtml:51
msgid "View all Steps"
msgstr "Voir toutes les Étapes"
......
msgid "Modify Artwork Group"
msgstr "Modifier l'Ensemble"
#: lib/mycyma.rb:32
msgid "Browser preference"
msgstr "Préférence du navigateur"
#: lib/mycyma.rb:33
msgid "English"
msgstr "Anglais"
#: lib/mycyma.rb:34
msgid "French"
msgstr "Français"

Also available in: Unified diff