Sha256: 36b33c8d3afb28b277f956c93a5f770b38ffdbc8c5b6ec3613f88bd74467b1da
Contents?: true
Size: 796 Bytes
Versions: 7
Compression:
Stored size: 796 Bytes
Contents
require 'inline' module Merb module Global module NumericProviders class Fork include Merb::Global::DateProviders::Base def localize(lang, number) pipe_rd, pipe_wr = IO.pipe # setlocale have no guarantee of being thread-safe so for safty # we fork the process. pid = fork do pipe_rd.close setlocale(lang.to_s) pipe_wr.write(number) pipe_wr.flush end pipe_wr.close Process.wait(pid) pipe_rd.read end inline do |builder| builder.include '<locale.h>' builder.c <<C void set_locale(const char *locale) { setlocale(LC_ALL, locale); } C end private :set_locale end end end end
Version data entries
7 entries across 7 versions & 1 rubygems