Rails的国际化

Posted on 2009年3月08日 07:44

国际化——I18N,很多软件都需要类似的功能,好在Rails2.2中有了简单实现。

不过,我要面临更复杂的问题:

  1. 国际化时,不但要替换相应的文本信息,还要做大面积的(基本就是全部)的页面布局调整;
  2. 国际化不是针对浏览器中比较通行的语言-地区(或者方言)的翻译互换,而是自定义的语言转换;

这个问题怎么解决?暂时还没有想好,只找到了两篇我认为可以借鉴的参考文献:

  1. Rails Internationalization (I18n) API
  2. Rails 2.2 Internationalization

Debian lenny下安装配置Rails开发环境

Posted on 2009年2月25日 16:49

Debian 5(lenny)已经正式发布了,相信很多朋友跟我一样,也用的是Debian。

那么,在Debian下,安装配置Rails开发环境是否能够顺利呢?跟我一起来一遍:

安装Ruby,这里使用lenny源里默认的ruby版本1.8.7:

sudo apt-get install ruby rdoc1.8 ri1.8

下载安装rubygems1.3.1。下载解压然后在该文件夹内执行

sudo ruby setup.rb

安装完毕,默认在/usr/bin下使用gem1.8作为gem的调用命令,因此做一个符号链接

sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

然后,安装rails

sudo gem i rails

安装完毕测试rails -v正常。安装mongrel

sudo gem i mongrel

出现类似于 

no such file to load -- mkmf (LoadError)

 的错误,可以通过安装ruby1.8-dev解决

sudo apt-get install ruby1.8-dev

如果出现的是类似于本地编译的错误,英文好像是native compile什么的,那你一定是没有安装编译包build-essential,使用Linux,这是必不可少的,一定要在安装完Linux系统后,首先就来这么一下

sudo apt-get install build-essential

书归正传,然后接着安装mongrel

sudo gem i mongrel

一切正常。安装Sqlite3

sudo apt-get install sqlite3 libsqlite3-0 libsqlite3-dev libsqlite3-ruby libsqlite3-ruby1.8
sudo gem i sqlite3-ruby
 接下来安装MySQL
sudo apt-get install mysql-server

然后安装MySQL的驱动

sudo gem i mysql

出错。经过Google,需要先

sudo apt-get install libmysqlclient15-dev

然后

sudo gem i mysql

 测试Rails

rails test
cd test
script/server

启动出错:

其中有类似“ no such file to load -- openssl (RuntimeError)”的句子

原来,需要

sudo apt-get install libopenssl-ruby1.8 openssl libssl-dev libopenssl-ruby

再次启动服务器

script/server

运行正常。

Rake的任务

Posted on 2009年2月20日 18:26

Rake常用的类似于 db:create等,都已被熟知,这次,想要查看所有的Rake任务,使用了命令

rake --task

显示任务如下:

rake db:abort_if_pending_migrations  # Raises an error if there are pending...
rake db:charset                      # Retrieves the charset for the curren...
rake db:collation                    # Retrieves the collation for the curr...
rake db:create                       # Create the database defined in confi...
rake db:create:all                   # Create all the local databases defin...
rake db:drop                         # Drops the database for the current R...
rake db:drop:all                     # Drops all the local databases define...
rake db:fixtures:identify            # Search for a fixture given a LABEL o...
rake db:fixtures:load                # Load fixtures into the current envir...
rake db:migrate                      # Migrate the database through scripts...
rake db:migrate:down                 # Runs the "down" for a given migratio...
rake db:migrate:redo                 # Rollbacks the database one migration...
rake db:migrate:reset                # Resets your database using your migr...
rake db:migrate:up                   # Runs the "up" for a given migration ...
rake db:reset                        # Drops and recreates the database fro...
rake db:rollback                     # Rolls the schema back to the previou...
rake db:schema:dump                  # Create a db/schema.rb file that can ...
rake db:schema:load                  # Load a schema.rb file into the database
rake db:sessions:clear               # Clear the sessions table
rake db:sessions:create              # Creates a sessions migration for use...
rake db:structure:dump               # Dump the database structure to a SQL...
rake db:test:clone                   # Recreate the test database from the ...
rake db:test:clone_structure         # Recreate the test databases from the...
rake db:test:prepare                 # Prepare the test database and load t...
rake db:test:purge                   # Empty the test database
rake db:version                      # Retrieves the current schema version...
rake doc:app                         # Build the app HTML Files
rake doc:clobber_app                 # Remove rdoc products
rake doc:clobber_plugins             # Remove plugin documentation
rake doc:clobber_rails               # Remove rdoc products
rake doc:plugins                     # Generate documentation for all insta...
rake doc:rails                       # Build the rails HTML Files
rake doc:reapp                       # Force a rebuild of the RDOC files
rake doc:rerails                     # Force a rebuild of the RDOC files
rake gems                            # List the gems that this rails applic...
rake gems:build                      # Build any native extensions for unpa...
rake gems:install                    # Installs all required gems for this ...
rake gems:unpack                     # Unpacks the specified gem into vendo...
rake gems:unpack:dependencies        # Unpacks the specified gems and its d...
rake log:clear                       # Truncates all *.log files in log/ to...
rake notes                           # Enumerate all annotations
rake notes:fixme                     # Enumerate all FIXME annotations
rake notes:optimize                  # Enumerate all OPTIMIZE annotations
rake notes:todo                      # Enumerate all TODO annotations
rake rails:freeze:edge               # Lock to latest Edge Rails, for a spe...
rake rails:freeze:gems               # Lock this application to the current...
rake rails:unfreeze                  # Unlock this application from freeze ...
rake rails:update                    # Update both configs, scripts and pub...
rake rails:update:configs            # Update config/boot.rb from your curr...
rake rails:update:javascripts        # Update your javascripts from your cu...
rake rails:update:scripts            # Add new scripts to the application s...
rake routes                          # Print out all defined routes in matc...
rake secret                          # Generate a crytographically secure s...
rake stats                           # Report code statistics (KLOCs, etc) ...
rake test                            # Run all unit, functional and integra...
rake test:functionals                # Run tests for functionalsdb:test:pre...
rake test:integration                # Run tests for integrationdb:test:pre...
rake test:plugins                    # Run tests for pluginsenvironment / R...
rake test:recent                     # Run tests for recentdb:test:prepare ...
rake test:uncommitted                # Run tests for uncommitteddb:test:pre...
rake test:units                      # Run tests for unitsdb:test:prepare /...
rake time:zones:all                  # Displays names of all time zones rec...
rake time:zones:local                # Displays names of time zones recogni...
rake time:zones:us                   # Displays names of US time zones reco...
rake tmp:cache:clear                 # Clears all files and directories in ...
rake tmp:clear                       # Clear session, cache, and socket fil...
rake tmp:create                      # Creates tmp directories for sessions...
rake tmp:pids:clear                  # Clears all files in tmp/pids
rake tmp:sessions:clear              # Clears all files in tmp/sessions
rake tmp:sockets:clear               # Clears all files in tmp/sockets
 

 

 

hello, programmer.

Posted on 2008年11月14日 23:17

测试一下。

prints "Hello, Programmer!"