Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
ユーザに言語を選択させる方法について
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
taichino  
View profile   Translate to Translated (View Original)
 More options Aug 4, 2:45 am
From: taichino <taich...@gmail.com>
Date: Mon, 3 Aug 2009 23:45:09 -0700 (PDT)
Local: Tues, Aug 4 2009 2:45 am
Subject: ユーザに言語を選択させる方法について
はじめまして。松本と申します。

ユーザに表示言語を選択させる方法について質問させて下さい。

現在 localeMiddlewareとテンプレート中のtransタグを利用して、
ブラウザの言語設定から言語が選択されるようにしているのですが、
それに加えてユーザがブラウザ設定言語とは別の言語を選択できるようにしたいと考えています。
ページ上に「日本語」「英語」というような言語切替リンクを張るイメージです。

特定のリンクを踏むとリクエストの言語設定を上書きして、セッション情報に埋め込むような
処理になるのかなと想像して、localeMiddlewareのドキュメント等を調べてみたのですが、
うまく情報を見つけられませんでした。

どのようにすれば「言語自動切替 + ユーザに言語選択の余地を残す」を実現できますでしょうか。

お手数ですが、ご教示頂けないでしょうか。


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
taichino  
View profile   Translate to Translated (View Original)
 More options Aug 4, 9:22 am
From: taichino <taich...@gmail.com>
Date: Tue, 4 Aug 2009 06:22:16 -0700 (PDT)
Local: Tues, Aug 4 2009 9:22 am
Subject: Re: ユーザに言語を選択させる方法について
松本です。

失礼致しました。

ドキュメントを読み飛ばしていました。
セッションにdjango_languageを書き込んで置けば、
ブラウザの言語設定(HTTPリクエストヘッダ)よりも優先して設定されるのですね。
http://djangoproject.jp/doc/ja/1.0/topics/i18n.html#id16

viewに以下のようなメソッドを用意して処理する事にしました。
---
def set_lang(request, lang):
  request.session['django_language'] = lang
  return HttpResponseRedirect('/path/to/redirect')
---

以上,お騒がせ致しました。

On 8月4日, 午後3:45, taichino <taich...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hiroshi Ayukawa  
View profile   Translate to Translated (View Original)
 More options Aug 5, 8:37 am
From: Hiroshi Ayukawa <ayukawa.hiro...@gmail.com>
Date: Wed, 5 Aug 2009 21:37:22 +0900
Local: Wed, Aug 5 2009 8:37 am
Subject: Re: [django-ja:898] Re: ユーザに言語を選択させる方法について
松本様

鮎川と申します。
POSTでの通信でよいのでしたら、viewが用意されています。
http://djangoproject.jp/doc/ja/1.0/topics/i18n.html#set-language
GETの場合に対応してないので、ちょっと使いにくいかもしれませんが。
(自分はこれのGET対応バージョンをどっかで書いて使ったこともあったように記憶しています。)

2009/08/04 22:22 に taichino<taich...@gmail.com> さんは書きました:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Taichi Matsumoto  
View profile   Translate to Translated (View Original)
 More options Aug 6, 1:18 pm
From: Taichi Matsumoto <taich...@gmail.com>
Date: Fri, 7 Aug 2009 02:18:22 +0900
Local: Thurs, Aug 6 2009 1:18 pm
Subject: Re: [django-ja:900] Re: ユーザに言語を選択させる方法について
鮎川様

松本です。

ご返信ありがとうございます。
既に機能として存在していたのですね!
確かにpostですと少し使いづらいので、
僕もgetバージョンを作って対応しようと思います。

ありがとうございました。

以上,よろしくお願い致します。

2009/08/05 21:37 に Hiroshi Ayukawa<ayukawa.hiro...@gmail.com> さんは書きました:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google