Royce  Reinger

Royce Reinger

1659360674

TTS: A Ruby Gem for Text-to-Speech By using Google Translate Service

tts

Using the Google Translate service as the speech engine, this gem generates a .mp3 voice file from any given string.

Usage

require 'tts'
# Will download "Hello World!.mp3" to your current directory
# Supported languages: ["zh", "en", "it", "fr"]
"Hello World!".to_file "en"

# i18n
"人民代表代表人民".to_file "zh"

# Save the file to a specific location
"Light rain with highs of 5 degrees".to_file "en", "~/weather.mp3"

# Supports large text files, as the gem will batch up the requests to Google (as each request max 100 chars)
text = "People living on the east coast of England have been warned to stay away from their homes because of further high tides expected later. The tidal surge that hit the UK is said to have been the worst for 60 years, with thousands abandoning their homes."
text.to_file "en"

#Direct playback (require mpg123 installed and in PATH with a POSIX system)
"Established in 1853, the University of Melbourne is a public-spirited institution that makes distinctive contributions to society in research, learning and teaching and engagement.".play

#Direct playback in other language (2 times)
 "Oggi il tempo è buono, andiamo in gita di esso.".play("it", 2)

#RTL Arabic language
"اليوم كان الطقس جيدا، ونحن نذهب في نزهة منه.".play("ar")

Direct play dependencies

You need to install `mpg123`

sudo apt-get install mpg123 #for debain based
brew install mpg123 #mac

CLI

tts "ruby is great"   # play the string.
text2mp3 "中国上海天气不错" "zh" #create mp3 file.

Versions

0.4 fixed issue that long text unable to generated.

0.5 added all supported languages, added direct playback feature fixed some broken rspec.

0.7 added CLI support

0.7.1 fixed new google API

Download Details: 

Author: c2h2
Source Code: https://github.com/c2h2/tts 
License: MIT license

#ruby #text #google 

What is GEEK

Buddha Community

TTS: A Ruby Gem for Text-to-Speech By using Google Translate Service
Chloe  Butler

Chloe Butler

1667425440

Pdf2gerb: Perl Script Converts PDF Files to Gerber format

pdf2gerb

Perl script converts PDF files to Gerber format

Pdf2Gerb generates Gerber 274X photoplotting and Excellon drill files from PDFs of a PCB. Up to three PDFs are used: the top copper layer, the bottom copper layer (for 2-sided PCBs), and an optional silk screen layer. The PDFs can be created directly from any PDF drawing software, or a PDF print driver can be used to capture the Print output if the drawing software does not directly support output to PDF.

The general workflow is as follows:

  1. Design the PCB using your favorite CAD or drawing software.
  2. Print the top and bottom copper and top silk screen layers to a PDF file.
  3. Run Pdf2Gerb on the PDFs to create Gerber and Excellon files.
  4. Use a Gerber viewer to double-check the output against the original PCB design.
  5. Make adjustments as needed.
  6. Submit the files to a PCB manufacturer.

Please note that Pdf2Gerb does NOT perform DRC (Design Rule Checks), as these will vary according to individual PCB manufacturer conventions and capabilities. Also note that Pdf2Gerb is not perfect, so the output files must always be checked before submitting them. As of version 1.6, Pdf2Gerb supports most PCB elements, such as round and square pads, round holes, traces, SMD pads, ground planes, no-fill areas, and panelization. However, because it interprets the graphical output of a Print function, there are limitations in what it can recognize (or there may be bugs).

See docs/Pdf2Gerb.pdf for install/setup, config, usage, and other info.


pdf2gerb_cfg.pm

#Pdf2Gerb config settings:
#Put this file in same folder/directory as pdf2gerb.pl itself (global settings),
#or copy to another folder/directory with PDFs if you want PCB-specific settings.
#There is only one user of this file, so we don't need a custom package or namespace.
#NOTE: all constants defined in here will be added to main namespace.
#package pdf2gerb_cfg;

use strict; #trap undef vars (easier debug)
use warnings; #other useful info (easier debug)


##############################################################################################
#configurable settings:
#change values here instead of in main pfg2gerb.pl file

use constant WANT_COLORS => ($^O !~ m/Win/); #ANSI colors no worky on Windows? this must be set < first DebugPrint() call

#just a little warning; set realistic expectations:
#DebugPrint("${\(CYAN)}Pdf2Gerb.pl ${\(VERSION)}, $^O O/S\n${\(YELLOW)}${\(BOLD)}${\(ITALIC)}This is EXPERIMENTAL software.  \nGerber files MAY CONTAIN ERRORS.  Please CHECK them before fabrication!${\(RESET)}", 0); #if WANT_DEBUG

use constant METRIC => FALSE; #set to TRUE for metric units (only affect final numbers in output files, not internal arithmetic)
use constant APERTURE_LIMIT => 0; #34; #max #apertures to use; generate warnings if too many apertures are used (0 to not check)
use constant DRILL_FMT => '2.4'; #'2.3'; #'2.4' is the default for PCB fab; change to '2.3' for CNC

use constant WANT_DEBUG => 0; #10; #level of debug wanted; higher == more, lower == less, 0 == none
use constant GERBER_DEBUG => 0; #level of debug to include in Gerber file; DON'T USE FOR FABRICATION
use constant WANT_STREAMS => FALSE; #TRUE; #save decompressed streams to files (for debug)
use constant WANT_ALLINPUT => FALSE; #TRUE; #save entire input stream (for debug ONLY)

#DebugPrint(sprintf("${\(CYAN)}DEBUG: stdout %d, gerber %d, want streams? %d, all input? %d, O/S: $^O, Perl: $]${\(RESET)}\n", WANT_DEBUG, GERBER_DEBUG, WANT_STREAMS, WANT_ALLINPUT), 1);
#DebugPrint(sprintf("max int = %d, min int = %d\n", MAXINT, MININT), 1); 

#define standard trace and pad sizes to reduce scaling or PDF rendering errors:
#This avoids weird aperture settings and replaces them with more standardized values.
#(I'm not sure how photoplotters handle strange sizes).
#Fewer choices here gives more accurate mapping in the final Gerber files.
#units are in inches
use constant TOOL_SIZES => #add more as desired
(
#round or square pads (> 0) and drills (< 0):
    .010, -.001,  #tiny pads for SMD; dummy drill size (too small for practical use, but needed so StandardTool will use this entry)
    .031, -.014,  #used for vias
    .041, -.020,  #smallest non-filled plated hole
    .051, -.025,
    .056, -.029,  #useful for IC pins
    .070, -.033,
    .075, -.040,  #heavier leads
#    .090, -.043,  #NOTE: 600 dpi is not high enough resolution to reliably distinguish between .043" and .046", so choose 1 of the 2 here
    .100, -.046,
    .115, -.052,
    .130, -.061,
    .140, -.067,
    .150, -.079,
    .175, -.088,
    .190, -.093,
    .200, -.100,
    .220, -.110,
    .160, -.125,  #useful for mounting holes
#some additional pad sizes without holes (repeat a previous hole size if you just want the pad size):
    .090, -.040,  #want a .090 pad option, but use dummy hole size
    .065, -.040, #.065 x .065 rect pad
    .035, -.040, #.035 x .065 rect pad
#traces:
    .001,  #too thin for real traces; use only for board outlines
    .006,  #minimum real trace width; mainly used for text
    .008,  #mainly used for mid-sized text, not traces
    .010,  #minimum recommended trace width for low-current signals
    .012,
    .015,  #moderate low-voltage current
    .020,  #heavier trace for power, ground (even if a lighter one is adequate)
    .025,
    .030,  #heavy-current traces; be careful with these ones!
    .040,
    .050,
    .060,
    .080,
    .100,
    .120,
);
#Areas larger than the values below will be filled with parallel lines:
#This cuts down on the number of aperture sizes used.
#Set to 0 to always use an aperture or drill, regardless of size.
use constant { MAX_APERTURE => max((TOOL_SIZES)) + .004, MAX_DRILL => -min((TOOL_SIZES)) + .004 }; #max aperture and drill sizes (plus a little tolerance)
#DebugPrint(sprintf("using %d standard tool sizes: %s, max aper %.3f, max drill %.3f\n", scalar((TOOL_SIZES)), join(", ", (TOOL_SIZES)), MAX_APERTURE, MAX_DRILL), 1);

#NOTE: Compare the PDF to the original CAD file to check the accuracy of the PDF rendering and parsing!
#for example, the CAD software I used generated the following circles for holes:
#CAD hole size:   parsed PDF diameter:      error:
#  .014                .016                +.002
#  .020                .02267              +.00267
#  .025                .026                +.001
#  .029                .03167              +.00267
#  .033                .036                +.003
#  .040                .04267              +.00267
#This was usually ~ .002" - .003" too big compared to the hole as displayed in the CAD software.
#To compensate for PDF rendering errors (either during CAD Print function or PDF parsing logic), adjust the values below as needed.
#units are pixels; for example, a value of 2.4 at 600 dpi = .0004 inch, 2 at 600 dpi = .0033"
use constant
{
    HOLE_ADJUST => -0.004 * 600, #-2.6, #holes seemed to be slightly oversized (by .002" - .004"), so shrink them a little
    RNDPAD_ADJUST => -0.003 * 600, #-2, #-2.4, #round pads seemed to be slightly oversized, so shrink them a little
    SQRPAD_ADJUST => +0.001 * 600, #+.5, #square pads are sometimes too small by .00067, so bump them up a little
    RECTPAD_ADJUST => 0, #(pixels) rectangular pads seem to be okay? (not tested much)
    TRACE_ADJUST => 0, #(pixels) traces seemed to be okay?
    REDUCE_TOLERANCE => .001, #(inches) allow this much variation when reducing circles and rects
};

#Also, my CAD's Print function or the PDF print driver I used was a little off for circles, so define some additional adjustment values here:
#Values are added to X/Y coordinates; units are pixels; for example, a value of 1 at 600 dpi would be ~= .002 inch
use constant
{
    CIRCLE_ADJUST_MINX => 0,
    CIRCLE_ADJUST_MINY => -0.001 * 600, #-1, #circles were a little too high, so nudge them a little lower
    CIRCLE_ADJUST_MAXX => +0.001 * 600, #+1, #circles were a little too far to the left, so nudge them a little to the right
    CIRCLE_ADJUST_MAXY => 0,
    SUBST_CIRCLE_CLIPRECT => FALSE, #generate circle and substitute for clip rects (to compensate for the way some CAD software draws circles)
    WANT_CLIPRECT => TRUE, #FALSE, #AI doesn't need clip rect at all? should be on normally?
    RECT_COMPLETION => FALSE, #TRUE, #fill in 4th side of rect when 3 sides found
};

#allow .012 clearance around pads for solder mask:
#This value effectively adjusts pad sizes in the TOOL_SIZES list above (only for solder mask layers).
use constant SOLDER_MARGIN => +.012; #units are inches

#line join/cap styles:
use constant
{
    CAP_NONE => 0, #butt (none); line is exact length
    CAP_ROUND => 1, #round cap/join; line overhangs by a semi-circle at either end
    CAP_SQUARE => 2, #square cap/join; line overhangs by a half square on either end
    CAP_OVERRIDE => FALSE, #cap style overrides drawing logic
};
    
#number of elements in each shape type:
use constant
{
    RECT_SHAPELEN => 6, #x0, y0, x1, y1, count, "rect" (start, end corners)
    LINE_SHAPELEN => 6, #x0, y0, x1, y1, count, "line" (line seg)
    CURVE_SHAPELEN => 10, #xstart, ystart, x0, y0, x1, y1, xend, yend, count, "curve" (bezier 2 points)
    CIRCLE_SHAPELEN => 5, #x, y, 5, count, "circle" (center + radius)
};
#const my %SHAPELEN =
#Readonly my %SHAPELEN =>
our %SHAPELEN =
(
    rect => RECT_SHAPELEN,
    line => LINE_SHAPELEN,
    curve => CURVE_SHAPELEN,
    circle => CIRCLE_SHAPELEN,
);

#panelization:
#This will repeat the entire body the number of times indicated along the X or Y axes (files grow accordingly).
#Display elements that overhang PCB boundary can be squashed or left as-is (typically text or other silk screen markings).
#Set "overhangs" TRUE to allow overhangs, FALSE to truncate them.
#xpad and ypad allow margins to be added around outer edge of panelized PCB.
use constant PANELIZE => {'x' => 1, 'y' => 1, 'xpad' => 0, 'ypad' => 0, 'overhangs' => TRUE}; #number of times to repeat in X and Y directions

# Set this to 1 if you need TurboCAD support.
#$turboCAD = FALSE; #is this still needed as an option?

#CIRCAD pad generation uses an appropriate aperture, then moves it (stroke) "a little" - we use this to find pads and distinguish them from PCB holes. 
use constant PAD_STROKE => 0.3; #0.0005 * 600; #units are pixels
#convert very short traces to pads or holes:
use constant TRACE_MINLEN => .001; #units are inches
#use constant ALWAYS_XY => TRUE; #FALSE; #force XY even if X or Y doesn't change; NOTE: needs to be TRUE for all pads to show in FlatCAM and ViewPlot
use constant REMOVE_POLARITY => FALSE; #TRUE; #set to remove subtractive (negative) polarity; NOTE: must be FALSE for ground planes

#PDF uses "points", each point = 1/72 inch
#combined with a PDF scale factor of .12, this gives 600 dpi resolution (1/72 * .12 = 600 dpi)
use constant INCHES_PER_POINT => 1/72; #0.0138888889; #multiply point-size by this to get inches

# The precision used when computing a bezier curve. Higher numbers are more precise but slower (and generate larger files).
#$bezierPrecision = 100;
use constant BEZIER_PRECISION => 36; #100; #use const; reduced for faster rendering (mainly used for silk screen and thermal pads)

# Ground planes and silk screen or larger copper rectangles or circles are filled line-by-line using this resolution.
use constant FILL_WIDTH => .01; #fill at most 0.01 inch at a time

# The max number of characters to read into memory
use constant MAX_BYTES => 10 * M; #bumped up to 10 MB, use const

use constant DUP_DRILL1 => TRUE; #FALSE; #kludge: ViewPlot doesn't load drill files that are too small so duplicate first tool

my $runtime = time(); #Time::HiRes::gettimeofday(); #measure my execution time

print STDERR "Loaded config settings from '${\(__FILE__)}'.\n";
1; #last value must be truthful to indicate successful load


#############################################################################################
#junk/experiment:

#use Package::Constants;
#use Exporter qw(import); #https://perldoc.perl.org/Exporter.html

#my $caller = "pdf2gerb::";

#sub cfg
#{
#    my $proto = shift;
#    my $class = ref($proto) || $proto;
#    my $settings =
#    {
#        $WANT_DEBUG => 990, #10; #level of debug wanted; higher == more, lower == less, 0 == none
#    };
#    bless($settings, $class);
#    return $settings;
#}

#use constant HELLO => "hi there2"; #"main::HELLO" => "hi there";
#use constant GOODBYE => 14; #"main::GOODBYE" => 12;

#print STDERR "read cfg file\n";

#our @EXPORT_OK = Package::Constants->list(__PACKAGE__); #https://www.perlmonks.org/?node_id=1072691; NOTE: "_OK" skips short/common names

#print STDERR scalar(@EXPORT_OK) . " consts exported:\n";
#foreach(@EXPORT_OK) { print STDERR "$_\n"; }
#my $val = main::thing("xyz");
#print STDERR "caller gave me $val\n";
#foreach my $arg (@ARGV) { print STDERR "arg $arg\n"; }

Download Details:

Author: swannman
Source Code: https://github.com/swannman/pdf2gerb

License: GPL-3.0 license

#perl 

Royce  Reinger

Royce Reinger

1659360674

TTS: A Ruby Gem for Text-to-Speech By using Google Translate Service

tts

Using the Google Translate service as the speech engine, this gem generates a .mp3 voice file from any given string.

Usage

require 'tts'
# Will download "Hello World!.mp3" to your current directory
# Supported languages: ["zh", "en", "it", "fr"]
"Hello World!".to_file "en"

# i18n
"人民代表代表人民".to_file "zh"

# Save the file to a specific location
"Light rain with highs of 5 degrees".to_file "en", "~/weather.mp3"

# Supports large text files, as the gem will batch up the requests to Google (as each request max 100 chars)
text = "People living on the east coast of England have been warned to stay away from their homes because of further high tides expected later. The tidal surge that hit the UK is said to have been the worst for 60 years, with thousands abandoning their homes."
text.to_file "en"

#Direct playback (require mpg123 installed and in PATH with a POSIX system)
"Established in 1853, the University of Melbourne is a public-spirited institution that makes distinctive contributions to society in research, learning and teaching and engagement.".play

#Direct playback in other language (2 times)
 "Oggi il tempo è buono, andiamo in gita di esso.".play("it", 2)

#RTL Arabic language
"اليوم كان الطقس جيدا، ونحن نذهب في نزهة منه.".play("ar")

Direct play dependencies

You need to install `mpg123`

sudo apt-get install mpg123 #for debain based
brew install mpg123 #mac

CLI

tts "ruby is great"   # play the string.
text2mp3 "中国上海天气不错" "zh" #create mp3 file.

Versions

0.4 fixed issue that long text unable to generated.

0.5 added all supported languages, added direct playback feature fixed some broken rspec.

0.7 added CLI support

0.7.1 fixed new google API

Download Details: 

Author: c2h2
Source Code: https://github.com/c2h2/tts 
License: MIT license

#ruby #text #google 

Akshaya 7

1608125898

Guide On How The Professional French Translation Services Work In India

French translation services are very much adequate for the people who want to convey their brand reports, information, and other essentials to the French clients or audience. If the businesses can convey with the clients in their native language, then probably the business will experience a progressive hike.

French is one of the best known European languages, and more than 80 million people across the globe speak this language. Therefore, if you are running an MNC, then you might need to leverage the opportunity for seeking sales or business from those 80 million people across the globe.
For better clarity, you must know that French is the second language for more than 100 million people across the globe. If you are wondering why you need the French translation services, then follow this article till the end to get the proper guide on how the professional French translation services can help you out.
At NNB Transtech, we provide All Foreign Language Translation Services.

Hiring Professional French Translation Services!

The professional French translation services offered by the major companies are to help the new and established companies reach out to the French-speaking audience or clients for better business. There are professional firms that are dedicated to offering the best translation services to the top MNCs with the help of subject matter translation experts.

The best part about hiring professionals is that they have a team of French experts who are proficient in different backgrounds. For instance, the professional French translators working in a firm are knowledgeable about Finance, healthcare, automobile, business, and other such niches. Therefore, accuracy is its prime commitment. So, the first step to avail the perfect French translation is to hire the best firm that is offering you ideal French translation services as per your needs and requirements within the specified budget.

The top corporations & organizations are very commonly in touch with clients and consumers all across the globe. Therefore, getting the documents and essentials translated into French is important for the companies to establish healthy communication with the French-speaking audience or clients.

Explain Your French Translation Project to the Professionals

The French translation service providers will assign a project manager for your translation needs. They are trained to understand and pen down everything you need and want to be mentioned in the translated document or promotional media.

Whether you seek French translation for websites or documents, you need to elaborate on the business or field it is related to. Once you do that, you will be asked for giving details on the facts and figures that you don’t want to be altered and should be present in the final output compulsorily.
The medical documents and accounting papers need to be perfectly accurate in terms of figures and facts. No business or individual will want it altered! The skilled employees are well aware of the facts and figures as they are subject matter experts.
But even then, they prefer taking instructions from the clients to overlook the work done before delivering it to the client.

After you explain your project, you will be given a deadline, and the work will begin. Irrespective of the complexity of the document, the professional translators will get it done without much hassle. The professional firms have the right certifications to handle your diverse translation projects.
Start of the Translation Project

After you have handed over your important document or other essential for the French translation, the experts will commence with the work. They have the right tools and expertise to start with quality translation work.

The professional French translation firms make sure to do the translation humanly. It is so because the machines are not accurate and it takes a lot of time to review the machine-translated documents. Therefore, to promote perfection in terms of the French translation, the professionals get it done by humans for utmost accuracy on priority.

Whether you have a medical, technical, financial, or legal document for translation, the experts are certified professionals in the respective background to handle your project. They will start as per your instructions that you stated in the previous step.

You can get the translated document in the desired format such as Adobe in Design, PowerPoint, MSWord, PDF, and others. If you are willing to get your documents translated from English to French without compromising on quality and at affordable pricing, seeking help from professionals is the best option for you.

Delivery of the Translated French Document

After the document has been translated, it is then sent to the review team to look at the accuracy of all the facts and figures. It is the job of the professionals to look after the accuracy of the documents to make them convey the right information to the French clients and consumers.
They are determined to offer you excellent quality, and for that, a proper review is highly demanded before the delivery of the work to the clients. Along with that, the professional firms are open for any type of edits as per the request from the clients.

The professionals leave no loopholes for bringing up the chances of edits. But even if you need more perfection, you can always reach out to your outsourced team to get the edits done without any additional charges. Therefore, the professionals are highly preferred for French translation overdoing it on your own.

Conclusion

These are the steps that act as the guide for you as well as the professional French translation firms to help you offer the best services at affordable pricing. You might be wondering whether to take the help of professional firms or hire an individual language expert.
An amateur language expert might not be proficient with tools and essentials to handle your multiple needs in the French translation project. You might be limited on the outputs by hiring individuals for your projects.

Therefore, it is better to seek help from professionals to help your business get the best benefits by putting up the best French translated documents for healthy communication with French-speaking clients or consumers across the globe.

#french translation services #spanish translation services #japanese translation services #german translation services #translation services

Royce  Reinger

Royce Reinger

1658891580

Ruby-gettext: A Pure Ruby Localization(L10n) Library & tool

gettext

gettext for Ruby

Gettext gem is a pure Ruby Localization(L10n) library and tool which is modeled after the GNU gettext package.

This library was called as "Ruby-GetText-Package". Since 2.3.0, this library is called just "gettext". You can call this library as "gettext gem" or "Ruby gettext" to distinguish from GNU gettext.

This library translates original messages to localized messages using client-side locale information(environment variable or CGI variable).

The tools for developers support creating, useing, and modifying localized message files(message catalogs).

Rails support has been removed.

Features

  • Translate singular/plural messages with simple APIs (similar to GNU gettext)
  • Thread safety. Message resources are shared from all threads, but returns translated messages of the current thread's locale.
  • Tools to find message IDs
    • Extract message IDs to po-files using rxgettext from
      • ruby scripts
      • glade-2 XML file (.glade)
      • ERB file (.rhtml, .erb)
      • Anything (with your own parsers)
      • The po-files are compatible with GNU gettext.
    • rmsgfmt creates a mo-file from a po-file. The mo-file is compatible with GNU gettext (msgfmt).
    • Using rxgettext/rmsgfmt as Rake tasks
  • textdomain's scope is adapt to ruby class/module mechanism.
    • A class/module can have plural textdomains.
    • a message is looked up in its class/module and ancestors.
  • CGI support (gettext/cgi)
    • Locale is retrieved from client informations using Ruby-Locale. (HTTP_ACCEPT_LANGUAGE, HTTP_ACCEPT_CHARSET, QUERY_STRING (lang), Cookies (lang)).

Requirements

gem install locale

For development:

  • Racc 1.4.3 or later (for compiling src/rmsgfmt.ry only)

Installation

Uninstall old gettext if exists. (You need to do this when updating 1.93.0 -> 2.0.1)

# sudo/su on POSIX system
gem uninstall gettext

RubyGems

# sudo/su on POSIX system
gem install gettext

Download tar-ball

# De-Compress archive and enter its top directory.
# sudo/su on POSIX system
ruby setup.rb

You can also install files in your favorite directory by supplying setup.rb some options. Try ruby setup.rb --help.

Usage

Translation

_() or gettext(): basic translation method

Translates the message, using the msgid if a translation is not found.

_("Hello") => "Bonjour"  # Found

This translation will appear in the po or pot file as:

msgid: "Hello"
msgstr: "Bonjour"

When a translation is not found it, it will return the msgid. This is a core benefit of gettext and applies to all its translation methods.

_("Hello") => "Hello"  # Not Found

Additional gettext methods come in 3 combinable flavors:

n_() or ngettext(): pluralized

Returns singular or plural form, depending on how many you have.

n_("Apple", "%{num} Apples", n) => "3 Pommes"  # When n = 3
n_("Apple", "%{num} Apple", n)  => "Pomme"     # When n = 1
n_(["Apple", "%{num} Apple"], n)  => "Pomme"   # 2 arg variation

This translation will appear in the po or pot file as:

msgid "Apple"
msgid_plural "%{num} Apples"
msgstr[0] "Pomme"
msgstr[1] "#{num} Pommes"

p_() or pgettext(): context aware

A context is a prefix to your translation, useful when one word has different meanings, depending on its context.

p_("Printer","Open") => "Öffnen" #translation found
p_("Printer","Open") => "Open"   #translation not found

This translation will appear in the po or pot file as:

msgctxt "Printer"
msgid "Open"
msgstr "Öffnen"

Note that the parser when sorting by msgid will strictly sort by the msgid ignoring the msgctxt. If you prefer to sort with the msgctxt you should consider the s_() method.

s_() or sgettext(): without context

The s_() method is very similar to the p_() method except that the context is inside the msgid.

s_("Printer|Open") => "Öffnen" #translation found
s_("Printer|Open") => "Open"   #translation not found
msgid "Printer|Open"
msgstr "Öffnen"

Note the the parser when sorting by msgid will take the context into consideration as it is part of the msgid unlike the p_() method.

Your preference of using s_() or p_() will depend on your translation workflow and process.

Combinations

You can combine n_() with either p_() or s_().

np_() or npgettext(): context aware pluralized

np_("Fruit", "Apple", "%{num} Apples", 3)
np_(["Fruit","Apple","%{num} Apples"], 3) # 2 arg variation
msgctxt "Fruit"
msgid "Apple"
msgid_plural "%{num} Apples"
msgstr[0] ""
msgstr[1] ""

sp_() or spgettext(): context aware pluralized

ns_("Fruit|Apple","%{num} Apples", 3)
ns_(["Fruit|Apple","%{num} Apples"], 3) # 2 arg variation
msgid "Fruit|Apple"
msgid_plural "%{num} Apples"
msgstr[0] ""
msgstr[1] ""

N_() and Nn_(): makes dynamic translation messages readable for the gettext parser

_(fruit) cannot be understood by the gettext parser. To help the parser find all your translations, you can add fruit = N_("Apple") which does not translate, but tells the parser: "Apple" needs translation.

fruit = N_("Apple")   # same as fruit = "Apple"
_(fruit)              # does a normal translation

fruits = Nn_("Apple", "%{num} Apples")
n_(fruits, 3)

Interpolating translations

This is not a feature of gettext but worth noting. You can interpolate translated strings without the ruby String % operator.

N_("active"); N_("inactive"); N_("paused") # possible value of status for parser to find.
_("Your account is #{account_state}.") % { account_state: _(status) }

Bind textdomains to the classes

A textdomain has a translation file in each language. A module/class can have multiple textdomains. This means the libraries/applications can have their own textdomains.

class Foo
  include GetText
  bindtextdomain "your_app_domain_name"
end

class Book
  include GetText
  bindtextdomain "general"
  bindtextdomain "book"
end

Locale

If you need to set the locale by yourself, then use:

GetText.locale = "en_US" # translate into english from now on
GetText.locale # => en_US

Or

include GetText
set_locale "en_US"

For more details and options, have a look at the samples folder.

License

This program is licenced under the same licence as Ruby (See doc/text/ruby-license.txt) or LGPL (Lesser General Public License: doc/text/lgpl-3.0.txt or http://www.gnu.org/licenses/lgpl-3.0.txt).

mofile.rb

Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
Copyright (C) 2001,2002 Masahiro Sakai <s01397ms at sfc.keio.ac.jp>

gettext.rb

Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
Copyright (C) 2001,2002 Masahiro Sakai <s01397ms at sfc.keio.ac.jp>

rxgettext

Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
Copyright (C) 2001,2002 Yasushi Shoji <yashi at atmark-techno.com>

Others

Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>

Translators

LanguageTranslatorStatus
Bosnian (bs)Sanjin Sehic <saserr at gmail.com>1.90.0 (old)
Bulgarian (bg)Sava Chankov <sava.chankov at gmail.com>2.0.1
Catalan (ca)Ramon Salvadó <rsalvado at gnuine.com>2.0.1
Chinese (Simplified)(zh_CN)Yang Bob <bob.yang.dev at gmail.com> (current) 
Yingfeng <blogyingfeng at gmail.com>
2.0.1
Chinese (Traditional)(zh_TW)Yang Bob <bob.yang.dev at gmail.com> (current) 
Lin Chung-Yi <xmarsh at gmail.com>
2.0.1
Croatian (hr)Sanjin Sehic <saserr at gmail.com>1.90.0 (old)
Czech (cs)Karel Miarka <kajism at yahoo.com>1.9.0 (old)
Dutch (nl)Menno Jonkers <ruby-gettext at jonkers.com>1.90.0 (old)
English (default) 2.1.0
Esperanto (eo)Malte Milatz <malte at gmx-topmail.de>2.0.1
Estonian (et)Erkki Eilonen <erkki at itech.ee>2.0.1
French (fr)Vincent Isambart <vincent.isambart at gmail.com> (current) 
David Sulc <davidsulc at gmail.com> 
Laurent Sansonetti <laurent.sansonetti at gmail.com>
2.0.1
German (de)Patrick Lenz <patrick at limited-overload.de> (current) 
Detlef Reichl <detlef.reichl at gmx.org> 
Sven Herzberg <herzi at abi02.de> 
Sascha Ebach <se at digitale-wertschoepfung.de>
2.0.1
Greek (el)Vassilis Rizopoulos <damphyr at gmx.net>2.0.1
Hungarian (hu)Tamás Tompa <tompata at gmail.com>2.0.1
Italian (it)Marco Lazzeri <marco.lazzeri at gmail.com> 
Gabriele Renzi <surrender_it at yahoo.it>
1.6.0 (old)
Japanese (ja)Masao Mutoh <mutomasa at gmail.com>2.1.0
Korean (ko)Gyoung-Yoon Noh <nohmad at gmail.com>1.9.0 (old)
Latvian (lv)Aivars Akots <aivars.akots at gmail.com>2.0.1
Norwegian (nb)Runar Ingebrigtsen <runar at mopo.no>2.0.1
Portuguese (Brazil)(pt_BR)Antonio S. de A. Terceiro <terceiro at softwarelivre.org> (current) 
Joao Pedrosa <joaopedrosa at gmail.com>
2.0.1
Russian (ru)Yuri Kozlov <kozlov.y at gmail.com>2.0.1
Serbian (sr)Slobodan Paunović <slobodan.paunovic at gmail.com>2.0.1
Spanish (es)David Espada <davinci at escomposlinux.org> (current) 
David Moreno Garza <damog at damog.net>
2.0.1
Swedish (sv)Nikolai Weibull <mailing-lists.ruby-talk at rawuncut.elitemail.org>0.8.0 (very old)
Ukrainian (uk)Alex Rootoff <rootoff at pisem.net>2.0.1
Vietnamese (vi)Ngoc Dao Thanh <ngocdaothanh at gmail.com>2.0.1

Maintainer

  • Kouhei Sutou <kou@clear-code.com>

Old maintainer

  • Masao Mutoh <mutomasa at gmail.com>

Links

NOTE: Gettext gem 3.0.0 removed many deprecated APIs and improves internal APIs. We want to keep backward compatibility as much as possible but some existing codes may be broken by gettext gem API change. If your code breaks by gettext gem 3.0.0, please report your problem. We will fix the problem and release a new version.

https://github.com/ruby-gettext/gettext is the official gettext gem repository. It is moved from https://github.com/mutoh/gettext . Mutoh agreed with the move.

Author: Ruby-gettext
Source Code: https://github.com/ruby-gettext/gettext 
License: 

#ruby #localization #text 

Vincent Lab

Vincent Lab

1605177504

Text to Speech in Node.js

In this video, I will be showing you how to turn text into speech in Node.js

#javascript #text to speech #javascript api #text to speech app #node.js text to speech #javascript text to speech