Merge branch '619-gender-aware-translations' of https://github.com/siefca/diaspora into inflections

Conflicts:
	Gemfile
	app/controllers/application_controller.rb
	app/controllers/posts_controller.rb
	app/controllers/publics_controller.rb
This commit is contained in:
MrZYX 2011-02-24 00:33:34 +01:00
commit 98cdee97c0
6 changed files with 152 additions and 0 deletions

View file

@ -26,6 +26,9 @@ gem 'will_paginate', '3.0.pre2'
#Statistics
gem 'googlecharts'
#Inflected translations
gem 'i18n-inflector-rails', '~> 1.0'
#Uncatagorized
gem 'roxml', :git => 'git://github.com/Empact/roxml.git', :ref => '7ea9a9ffd2338aaef5b0'
gem 'addressable', '2.2.2', :require => 'addressable/uri'

View file

@ -13,6 +13,9 @@ class ApplicationController < ActionController::Base
before_filter :set_git_header
before_filter :which_action_and_user
prepend_before_filter :clear_gc_stats
before_filter :set_grammatical_gender
inflection_method :grammatical_gender => :gender
def set_contacts_notifications_and_status
if user_signed_in?
@ -68,4 +71,40 @@ class ApplicationController < ActionController::Base
redirect_to root_url
end
end
def set_grammatical_gender
if (user_signed_in? && I18n.inflector.inflected_locale?)
gender = current_user.profile.gender.to_s.tr('!()[]"\'`*=|/\#.,-:', '').downcase
unless gender.empty?
i_langs = I18n.inflector.inflected_locales(:gender)
i_langs.delete I18n.locale
i_langs.unshift I18n.locale
i_langs.each do |lang|
token = I18n.inflector.true_token(gender, :gender, lang)
unless token.nil?
@grammatical_gender = token
break
end
end
end
end
end
def grammatical_gender
@grammatical_gender || nil
end
def similar_people contact, opts={}
opts[:limit] ||= 5
aspect_ids = contact.aspect_ids
count = Contact.count(:user_id => current_user.id,
:person_id.ne => contact.person.id,
:aspect_ids.in => aspect_ids)
if count > opts[:limit]
offset = rand(count-opts[:limit])
else
offset = 0
end
end
end

View file

@ -8,6 +8,7 @@ class PostsController < ApplicationController
skip_before_filter :set_invites
skip_before_filter :set_locale
skip_before_filter :which_action_and_user
skip_before_filter :set_grammatical_gender
def show
@post = Post.where(:id => params[:id], :public => true).includes(:person, :comments => :person).first

View file

@ -11,6 +11,7 @@ class PublicsController < ApplicationController
skip_before_filter :set_invites
skip_before_filter :set_locale
skip_before_filter :which_action_and_user
skip_before_filter :set_grammatical_gender
layout false
caches_page :host_meta

View file

@ -0,0 +1,44 @@
all:
i18n:
inflections:
gender:
f: "female"
m: "male"
n: "neuter"
masculine: @m
male: @m
man: @m
boy: @m
b: @m
he: @m
sir: @m
mr: @m
mister: @m
guy: @m
dude: @m
gentleman: @m
mal: @m
female: @f
feminine: @f
girl: @f
g: @f
lady: @f
she: @f
miss: @f
missus: @f
mrs: @f
missis: @f
mistress: @f
ms: @f
neuter: @n
neutral: @n
it: @n
they: @n
impersonal: @n
default: n

View file

@ -0,0 +1,64 @@
pl:
i18n:
inflections:
gender:
f: "rodzaj żeński"
m: "rodzaj męski"
n: "rodzaj nijaki"
masculine: @m
facet: @m
chłop: @m
chłopak: @m
chłopek: @m
chłopiec: @m
chłopaczek: @m
mąż: @m
prawiczek: @m
prawik: @m
boj: @m
woj: @m
gość: @m
gostek: @m
gościu: @m
samiec: @m
samczyk: @m
kawaler: @m
mężczyzna: @m
męski: @m
pani: @f
kobieta: @f
k: @f
kobietka: @f
dziewczyna: @f
dziewczę: @f
baba: @f
babka: @f
facetka: @f
dziewczynka: @f
dziewica: @f
niewiasta: @f
samica: @f
samiczka: @f
ona: @f
panna: @f
pannica: @f
panienka: @f
żeński: @f
laska: @f
lasencja: @f
żona: @f
dziewoja: @f
neuter: @n
to: @n
ono: @n
dziecko: @n
ktoś: @n
coś: @n
impersonal: @n
nijaki: @n
default: n