Skip to content

Commit

Permalink
Merge remote branch 'official/master'
Browse files Browse the repository at this point in the history
* official/master:
  added more locales
  Localisation updates from http://translatewiki.net
  unvendorize devise
  update warden
  added pl and pt-BR to default locales
  Localisation updates from http://translatewiki.net
  Add new locale 'pt-BR'
  Add new locale 'pl'
  L10n updates.
  Constrain(t)s -> Requirements
  answered, not accepted
  Fix typo
  Various L10n updates for English.
  Remove stray file.
  capitalized some strings
  fix i18n typo
  Fix typos and improve language. Some issues were spotted by kgh from translatewiki.net.
  validate that the negative value of the undo reward is superior to the value of the reward for voting and fix the reputation increment on voting
  • Loading branch information
Helder Ribeiro committed Jul 10, 2010
2 parents 9d965d3 + 116a140 commit 579186d
Show file tree
Hide file tree
Showing 283 changed files with 1,742 additions and 9,080 deletions.
6 changes: 4 additions & 2 deletions app/models/answer.rb
Expand Up @@ -53,9 +53,11 @@ def on_add_vote(v, voter)

def on_remove_vote(v, voter)
if v > 0
self.user.upvote!(self.group, -1)
self.user.update_reputation(:answer_undo_up_vote, self.group)
voter.on_activity(:undo_vote_up_answer, self.group)
else
self.user.downvote!(self.group, -1)
self.user.update_reputation(:answer_undo_down_vote, self.group)
voter.on_activity(:undo_vote_down_answer, self.group)
end
end

Expand Down
41 changes: 31 additions & 10 deletions app/models/group.rb
Expand Up @@ -224,19 +224,40 @@ def self.humanize_reputation_rewards(key)
end

def check_reputation_configs
self.reputation_constrains.each do |k,v|
self.reputation_constrains[k] = v.to_i
if !REPUTATION_CONSTRAINS.has_key?(k)
self.errors.add(:reputation_constrains, "Invalid key")
return false
if self.reputation_constrains_changed?
self.reputation_constrains.each do |k,v|
self.reputation_constrains[k] = v.to_i
if !REPUTATION_CONSTRAINS.has_key?(k)
self.errors.add(:reputation_constrains, "Invalid key")
return false
end
end
end

self.reputation_rewards.each do |k,v|
self.reputation_rewards[k] = v.to_i
if !REPUTATION_REWARDS.has_key?(k)
self.errors.add(:reputation_rewards, "Invalid key")
return false
if self.reputation_rewards_changed?
valid = true
[["vote_up_question", "undo_vote_up_question"],
["vote_down_question", "undo_vote_down_question"],
["question_receives_up_vote", "question_undo_up_vote"],
["question_receives_down_vote", "question_undo_down_vote"],
["vote_up_answer", "undo_vote_up_answer"],
["vote_down_answer", "undo_vote_down_answer"],
["answer_receives_up_vote", "answer_undo_up_vote"],
["answer_receives_down_vote", "answer_undo_down_vote"],
["answer_picked_as_solution", "answer_unpicked_as_solution"]].each do |action, undo|
if self.reputation_rewards[action].to_i > (self.reputation_rewards[undo].to_i*-1)
valid = false
self.errors.add(undo, "should be less than #{(self.reputation_rewards[action].to_i)*-1}")
end
end
return false unless valid

self.reputation_rewards.each do |k,v|
self.reputation_rewards[k] = v.to_i
if !REPUTATION_REWARDS.has_key?(k)
self.errors.add(:reputation_rewards, "Invalid key")
return false
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/question.rb
Expand Up @@ -146,10 +146,10 @@ def on_add_vote(v, voter)
def on_remove_vote(v, voter)
if v > 0
self.user.update_reputation(:question_undo_up_vote, self.group)
voter.on_activity(:undo_vote_up_question, self.group)
voter.on_activity(:vote_up_question, self.group)
else
self.user.update_reputation(:question_undo_down_vote, self.group)
voter.on_activity(:undo_vote_down_question, self.group)
voter.on_activity(:vote_down_question, self.group)
end
on_activity(false)
end
Expand Down
22 changes: 7 additions & 15 deletions app/models/user.rb
Expand Up @@ -284,9 +284,7 @@ def on_activity(activity, group)
if activity == :login
self.last_logged_at ||= Time.now
if !self.last_logged_at.today?
self.collection.update({:_id => self._id},
{:$set => {:last_logged_at => Time.zone.now.utc}},
{:upsert => true})
self.set( {:last_logged_at => Time.zone.now.utc} )
end
else
self.update_reputation(activity, group) if activity != :login
Expand All @@ -299,14 +297,10 @@ def activity_on(group, date)
last_day = config_for(group).last_activity_at

if last_day != day
collection.update({:_id => self.id},
{:$set => {"membership_list.#{group.id}.last_activity_at" => day}},
{:upsert => true})
self.set({"membership_list.#{group.id}.last_activity_at" => day})
if last_day
if last_day.utc.between?(day.yesterday - 12.hours, day.tomorrow)
collection.update({:_id => self.id},
{:$inc => {"membership_list.#{group.id}.activity_days" => 1}},
{:upsert => true})
self.increment({"membership_list.#{group.id}.activity_days" => 1})
Magent.push("actors.judge", :on_activity, group.id, self.id)
elsif !last_day.utc.today? && (last_day.utc != Time.now.utc.yesterday)
Rails.logger.info ">> Resetting act days!! last known day: #{last_day}"
Expand All @@ -317,17 +311,15 @@ def activity_on(group, date)
end

def reset_activity_days!(group)
self.collection.update({:_id => self._id},
{:$set => {"membership_list.#{group.id}.activity_days" => 0}},
:upsert => true)
self.set({"membership_list.#{group.id}.activity_days" => 0})
end

def upvote!(group, v = 1.0)
collection.update({:_id => self.id}, {:$inc => {"membership_list.#{group.id}.votes_up" => v.to_f}}, {:upsert => true})
self.increment({"membership_list.#{group.id}.votes_up" => v.to_f})
end

def downvote!(group, v = 1.0)
collection.update({:_id => self.id}, {:$inc => {"membership_list.#{group.id}.votes_down" => v.to_f}}, {:upsert => true})
self.increment({"membership_list.#{group.id}.votes_down" => v.to_f})
end

def update_reputation(key, group)
Expand All @@ -337,7 +329,7 @@ def update_reputation(key, group)
current_reputation = config_for(group).reputation

if value
collection.update({:_id => self.id}, {:$inc => {"membership_list.#{group.id}.reputation" => value}}, {:upsert => true})
self.increment({"membership_list.#{group.id}.reputation" => value})
end

stats = self.reputation_stats(group, { :select => [:_id] })
Expand Down
4 changes: 2 additions & 2 deletions config/environment.rb
Expand Up @@ -35,8 +35,8 @@
config.gem "magent", :version => "0.4"
config.gem "differ", :version => "0.1.1"
config.gem 'super_exception_notifier', :version => '~> 2.0.0', :lib => 'exception_notifier'
config.gem "warden", :version => "0.10.3"
config.gem "devise", :version => "1.0.7"
config.gem "warden", :version => "0.10.7"
config.gem "dcu-devise", :version => "1.0.7", :lib => "devise"
config.gem "twitter-text", :version => "1.1.1"
config.gem "oauth2", :version => "0.0.8"
config.gem "twitter_oauth", :version => "0.3.6"
Expand Down
10 changes: 8 additions & 2 deletions config/initializers/01_locales.rb
Expand Up @@ -2,11 +2,15 @@
I18n.backend.store_translations 'en', {}
I18n.backend.store_translations 'fr', {}
I18n.backend.store_translations 'pt-PT', {}
I18n.backend.store_translations 'pt-BR', {}
I18n.backend.store_translations 'ja', {}
I18n.backend.store_translations 'el', {}
I18n.backend.store_translations 'ar', {}
I18n.backend.store_translations 'be-TARASK', {}
I18n.backend.store_translations 'br', {}
I18n.backend.store_translations 'bs', {}
I18n.backend.store_translations 'de', {}
I18n.backend.store_translations 'eo', {}
I18n.backend.store_translations 'fi', {}
I18n.backend.store_translations 'gl', {}
I18n.backend.store_translations 'ia', {}
Expand All @@ -15,7 +19,9 @@
I18n.backend.store_translations 'mk', {}
I18n.backend.store_translations 'nl', {}
I18n.backend.store_translations 'nb', {}
I18n.backend.store_translations 'pl', {}
I18n.backend.store_translations 'pms', {}
I18n.backend.store_translations 'ps', {}
I18n.backend.store_translations 'ru', {}
I18n.backend.store_translations 'te', {}
I18n.backend.store_translations 'tl', {}
Expand All @@ -25,11 +31,11 @@
# You need to "force-initialize" loaded locales
I18n.backend.send(:init_translations)

AVAILABLE_LOCALES = ["be-TARASK", "br", "de", "el", "en", "es-419", "fi", "fr", "gl", "ia", "ja", "ko", "lb", "mk", "nb", "nl", "pms", "pt-PT", "ru", "te", "tl"] #I18n.backend.available_locales.map { |l| l.to_s }
AVAILABLE_LOCALES = ["ar", "be-TARASK", "br", "bs", "de", "eo", "el", "en", "es-419", "fi", "fr", "gl", "ia", "ja", "ko", "lb", "mk", "nb", "nl", "pms", "ps", "pl", "pt-BR", "pt-PT", "ru", "te", "tl"] #I18n.backend.available_locales.map { |l| l.to_s }
AVAILABLE_LANGUAGES = I18n.backend.available_locales.map { |l| l.to_s.split("-").first}.uniq

## this is only for the user settings, not related to translatewiki
DEFAULT_USER_LANGUAGES = ['en', 'es-419', 'fr', 'pt-PT', 'ja', 'el', 'de', 'ko', 'nl', 'ru', 'tl', 'it']
DEFAULT_USER_LANGUAGES = ['en', 'es-419', 'fr', 'pl', 'pt-BR', 'pt-PT', 'ja', 'el', 'de', 'ko', 'nl', 'ru', 'tl', 'it']

RAILS_DEFAULT_LOGGER.debug "* Loaded locales: #{AVAILABLE_LOCALES.inspect}"

Expand Down
15 changes: 15 additions & 0 deletions config/locales/ads/ar.yml
@@ -0,0 +1,15 @@
# Messages for Arabic (العربية)
# Exported from translatewiki.net
# Export driver: syck
# Author: عمرو
ar:
ads:
ad_links: أضف إعلان {{type}} جديد
create:
success: تم إنشاء الإعلان بنجاح
index:
add_adsense: أضف إعلان Google جديد
title: إعلانات
name: "الاسم:"
position: "الموضع:"
title: أضف إعلان {{type}} جديد
16 changes: 16 additions & 0 deletions config/locales/ads/pl.yml
@@ -0,0 +1,16 @@
# Messages for Polish (Polski)
# Exported from translatewiki.net
# Export driver: syck
# Author: Sp5uhe
pl:
ads:
ad_links: Dodaj nową {{type}} reklamę
create:
success: Reklama została utworzona.
index:
add_adbard: Dodaj nowy billboard reklamowy
add_adsense: Dodaj nową reklamę kontekstową google
title: Reklamy
name: Nazwa
position: Pozycja
title: Dodaj nową {{type}} reklamę
8 changes: 4 additions & 4 deletions config/locales/ads/pt-PT.yml
Expand Up @@ -6,13 +6,13 @@
# Author: McDutchie
pt-PT:
ads:
ad_links: Adicionar um novo anúncio {{type}}
ad_links: Adicionar um anúncio {{type}} novo
create:
success: O anúncio foi criado com êxito.
success: O anúncio foi criado.
index:
add_adbard: Adicionar um anúncio Ad Bard novo
add_adsense: Adicionar um novo anúncio do Google AdSense
add_adsense: Adicionar um anúncio do Google AdSense novo
title: Anúncios
name: "Nome:"
position: "Posição:"
title: Adicionar um novo anúncio {{type}}
title: Adicionar um anúncio {{type}} novo
20 changes: 20 additions & 0 deletions config/locales/announcements/ar.yml
@@ -0,0 +1,20 @@
# Messages for Arabic (العربية)
# Exported from translatewiki.net
# Export driver: syck
# Author: عمرو
ar:
activerecord:
attributes:
announcement:
ends_at: تنتهي في
message: رسالة
only_anonymous: فقط للمستخدمين المجهولين
starts_at: تبدأ في
announcements:
actions:
delete: إزالة
title: الإجراءات
create:
success: تم إنشاء البلاغ بنجاح
index:
title: البلاغات
4 changes: 2 additions & 2 deletions config/locales/announcements/nl.yml
Expand Up @@ -15,6 +15,6 @@ nl:
delete: verwijderen
title: Handelingen
create:
success: de aankondiging is aangemaakt.
success: De aankondiging is aangemaakt.
index:
title: aankondigingen
title: Aankondigingen
20 changes: 20 additions & 0 deletions config/locales/announcements/pl.yml
@@ -0,0 +1,20 @@
# Messages for Polish (Polski)
# Exported from translatewiki.net
# Export driver: syck
# Author: Sp5uhe
pl:
activerecord:
attributes:
announcement:
ends_at: Zakończ
message: Komunikat
only_anonymous: Tylko dla anonimowych użytkowników
starts_at: Rozpocznij
announcements:
actions:
delete: Usuń
title: Działania
create:
success: Ogłoszenie zostało utworzone.
index:
title: Ogłoszenia
13 changes: 7 additions & 6 deletions config/locales/announcements/pt-PT.yml
@@ -1,19 +1,20 @@
# Messages for Portuguese (Português)
# Exported from translatewiki.net
# Export driver: syck
# Author: Hamilton Abreu
pt-PT:
activerecord:
attributes:
announcement:
ends_at: ends at
message: message
only_anonymous: only for anonymous users
message: Mensagem
only_anonymous: Só para utilizadores anónimos
starts_at: starts at
announcements:
actions:
delete: remove
title: actions
delete: Remover
title: Acções
create:
success: announcement was successfully created.
success: A notificação do site foi criada.
index:
title: announcements
title: Notificações do site
25 changes: 25 additions & 0 deletions config/locales/answers/ar.yml
@@ -0,0 +1,25 @@
# Messages for Arabic (العربية)
# Exported from translatewiki.net
# Export driver: syck
# Author: عمرو
ar:
activerecord:
attributes:
answer:
body: نص الرسالة
created_at: مجاب
link: الرابط
models:
answer: إجابة
answers: إجابات
answers:
create:
flash_error: "حدث شيئا ما أثناء إضافة جوابك.\nتذكر أن:\n- الأجوبة الفارغة والمكررة غير مسموحة\n- يجب عليك الانتظار 20 ثانية قبل إضافة إجابة أخرى.\n- لا يمكنك إضافة أكثر من إجابة واحدة لنفس السؤال."
flash_notice: شكرا لك!
form:
answer_label: أجب على السؤال
comment_label: عّلق على هذه الإجابة
comment_submit: عّلق
submit: إجابة
revert:
title: أعد الجواب
2 changes: 1 addition & 1 deletion config/locales/answers/de.yml
Expand Up @@ -22,7 +22,7 @@ de:
form:
answer_label: Frage beantworten
comment_label: Antwort kommentieren
comment_submit: Kommentar
comment_submit: Kommentieren
submit: Antwort
revert:
title: Antwort entfernen
Expand Down
4 changes: 2 additions & 2 deletions config/locales/answers/en.yml
Expand Up @@ -12,8 +12,8 @@ en:
flash_error: "Something went wrong adding your answer.
\n Remember that:
\n - Empty and repeated answers are not allowed
\n - You need to wait 20 senconds before posting another answer.
\n - You can only post one answer by question."
\n - You need to wait 20 seconds before posting another answer.
\n - You can only post one answer per question."
update:
flash_notice: "Answer was successfully updated."
revert:
Expand Down
25 changes: 25 additions & 0 deletions config/locales/answers/eo.yml
@@ -0,0 +1,25 @@
# Messages for Esperanto (Esperanto)
# Exported from translatewiki.net
# Export driver: syck
# Author: ArnoLagrange
eo:
activerecord:
attributes:
answer:
created_at: Respondita
link: Ligilo
answers:
create:
flash_error: "Io malĝuste funkciis dum aldono de via respondo. \n Memoru tion: \n - Malplenaj kaj ripetitaj respondoj ne estas permesitaj \n - Vi devas atendi 20 sekundojn antaŭ ol sendi alian respondon. \n - Vi povas sendi po nur unu respondon por ĉiu demando."
flash_notice: Dankon!
edit:
title: Redakti respondon
form:
answer_label: Respondi la demandon
comment_label: Rimarko pri ĉi tiu respondo
comment_submit: Komento
submit: Respondo
revert:
title: Malfari respondon
update:
flash_notice: Respondo estis sukcese ĝisdatigita.
2 changes: 1 addition & 1 deletion config/locales/answers/nb.yml
Expand Up @@ -2,7 +2,7 @@
# Exported from translatewiki.net
# Export driver: syck
# Author: Nghtwlkr
"no":
nb:
activerecord:
models:
answer: Svar
Expand Down

0 comments on commit 579186d

Please sign in to comment.