Giter Site home page Giter Site logo

scsmith / language_list Goto Github PK

View Code? Open in Web Editor NEW
90.0 90.0 32.0 380 KB

A list of languages based upon ISO-639-1 and ISO-639-3 with functions to retrieve only common languages.

Ruby 100.00%
common-language countries iso-639 iso-639-1 iso-639-3 language ruby

language_list's People

Contributors

andyatkinson avatar dougo avatar jeremyhaile avatar jrochkind avatar luispcosta avatar mainameiz avatar molgin avatar patrickdet avatar scsmith avatar tmaier avatar wedtm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

language_list's Issues

FYI: TwitterCLDR

I just noticed that the pretty cool TwitterCLDR gem has some similar functionality to language_list, possibly includes everything language_list does plus a lot more?

(Including a lot of unicode localization stuff unrelated to language lists, but also even more language code standards, and knowledge of language names in multiple languages, like "espanol" etc. )

https://github.com/twitter/twitter-cldr-rb

Common in which context?

Which context do you assume that these languages are common in? is it comparative on the global scale, or is it per country or per region per country?

un-doc'd changes between 1.1.0 and 1.2.0

In 1.1.0, you can do LanguageList::LanguageInfo.find(nil), and get nil back. In 1.2.0, you get

NoMethodError: undefined method `downcase!' for nil:NilClass
	from /Users/jrochkind/.gem/ruby/2.4.0/gems/language_list-1.2.0/lib/language_list.rb:65:in `find'

Probably related, it's also mutating the argument passed in.

str = "German"
LanguageList::LanguageInfo.find(str)
str # is now "german" not "German"

I don't want it mutating the arguments passed in, that's a bad practice.

Both of these things caused my build to fail upgrading from 1.1.0 to 1.2.0

Issues generating a select languages list

Thanks very much for assembling the list of languages.

We needed a select tag of common languages, but with English and Spanish shown first. We also wanted to list both Mandarin and Cantonese, and remove the parentheticals. We used iso_639_3 to get a code for Cantonese. Others may find this useful:

# app/application_helper.rb

  def our_languages
    # Fix names, add Cantonese, and bring English and Spanish to the front
    LanguageList::COMMON_LANGUAGES.map do |language|
      [language.name.gsub('Modern Greek (1453-)', 'Greek')
        .gsub('Tonga (Tonga Islands)', 'Tongan')
        .gsub('Chinese', 'Chinese Mandarin'),
       language.iso_639_3]
    end.push(['Chinese Cantonese', 'yue']).sort.promote(%w(Spanish spa))
      .promote(%w(English eng))
  end

  class ActionView::Helpers::FormBuilder
    # http://stackoverflow.com/a/2625727/1935918
    include ApplicationHelper
    include ActionView::Helpers::FormTagHelper
    include ActionView::Helpers::FormOptionsHelper

    def language_select(name, options = { include_blank: true })
      select_tag "#{@object_name}[#{name}]",
                 options_for_select(our_languages,
                                    selected: @object.send(name)), options
    end

  class Array
    def promote(promoted_element)
      return self unless (found_index = find_index(promoted_element))
      unshift(delete_at(found_index))
    end
  end

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.