Giter Club home page Giter Club logo

conchiterz's Introduction

Build Status Gem Version

Conchiterz

A simple gem to feminize french word/sentence.

  • Keep intact upcase, downcase and capitalize letters.
  • Allows you to escape some words if you does not want feminize them.
  • Handle and return punctuation according the french rules. (.;:!...,?)
  • Keep intact word with accent. (éèêâàûôî)
  • Handle some special character. ('-%)

Installation

Add this line to your application's Gemfile:

gem 'conchiterz'

And then execute:

$ bundle

Or install it yourself as:

$ gem install conchiterz

Get started

Conchiterz.translate(string, boolean, escape = []) feminize a french string if boolean is evaluates to true.

Use on your CLI :

[1] pry(main)> require 'conchiterz'
=> true
[2] pry(main)> Conchiterz.translate('Vous vous êtes inscrit avec succès.', true)
=> "Vous vous êtes inscrite avec succès."

If you give feminine string whatever the boolean value, the same string will be returned.

Escaping words

Sometimes in french you should have the need to not feminize some word in function of the context of your sentence.

Take the following code and sentence:

Conchiterz.translate('Nous vous souhaitons un joyeux réveillon, soyez heureux en 2018'
, true)

We don't want the following result:

'Nous vous souhaitons une joyeuse réveillon, soyez heureuse en 2018'

Because 'un joyeux réveillon' is invariable in french.

In this way let's introduce the escape option.

Just add an array of which words you not wanted to feminize, check the following code:

[1] pry(main)> require 'conchiterz'
=> true
[2] pry(main)> Conchiterz.translate('Nous vous souhaitons un joyeux réveillon, soyez heureux en 2018'
, true, ['un', 'joyeux'])
=> 'Nous vous souhaitons un joyeux réveillon, soyez heureuse en 2018'

Et voila! Easy to feminize your sentence still understandable by french speaker.

Rails

It adds String#conchiterz(boolean, escape = [])

If you just want to feminize a sentence add in your view,

# app/views/pratiquants/show.html.erb

<%= 'Vous êtes bien inscrit à notre newsletter.'.conchiterz(@pratiquant.female?) %>

Will return

"Vous êtes bien inscrite à notre newsletter."

if your pratiquant is a female.

Escaping words

You wanted to escape some words? Just add these words inside an array and pass it as argument, as follow..

# app/views/pratiquants/show.html.erb

<%= 'Nous vous souhaitons un joyeux réveillon et soyez heureux en 2018'.conchiterz(@pratiquant.female?,['un', 'joyeux']) %>

Will return

'Nous vous souhaitons un joyeux réveillon et soyez heureuse en 2018'

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/morissetcl/conchiterz. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

conchiterz's People

Contributors

morissetcl avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.