Topic: Url Localization translation internationalization
Hi all
I have a problem in url localization using ruby I have a script in public/scripts and whn i run it it creates a buch of xml files with urls, but i cant make the urls correcltly for different languages how can i do that? like for usa.yml it includes other language words in the url.... wats wrong in the code
+++++++++++++Here is the code +++++++++++++++++++
def makeSitemap(data, file, url_prefix, freq, prio)
print "Erstelle " + file + " (" + data.length.to_s + " Eintraege) ... "
now = w3c_date($time_start) # actual time
xml_str = ""
xml = Builder::XmlMarkup.new(:target => xml_str, :indent => 1)
xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
data.each do |i|
xml.url do
xml.loc url_prefix + i["url"]
xml.lastmod now
xml.changefreq((i.include?"freq")? i["freq"]: freq)
xml.priority((i.include?"prio")? i["prio"]: prio)
end
end
end
File.open(RAILS_ROOT + file, 'w') do |f|
gz = Zlib::GzipWriter.new(f)
gz.write xml_str
gz.close
end
puts "erledigt."
end
def sitemap_jobs(country_version_id, sitemaps_dir)
functions = Function.find(:all, :conditions => {:country_version_id => country_version_id})
return if functions.empty?
functions.each do |function|
jobs = Job.find(:all, :conditions => {:country_version_id => country_version_id, :function_id => function.id})
if jobs.length > 0
data = []
jobs.each do |job|
data.push("url" => url_for(:controller => 'jobs', :action => 'show', :title_urlified_with_job_ref_id => job.title_urlified + "-" + job.id.to_s))
end
filename="job_" + function.id.to_s + "_sitemap.xml.gz"
makeSitemap(data, sitemaps_dir + filename, "", "daily", 0.4)
$sitemaps.push(filename)
end
end
end
Last edited by gikian (2011-11-28 18:31:35)