DEV Community

Cover image for random-fruits-name.js is npm package that just generates random fruit names
Yuki Shindo
Yuki Shindo

Posted on

random-fruits-name.js is npm package that just generates random fruit names

A last year, I made a very simple npm package. It is a package named random-fruits-name.js.

random-fruits-name.js - Generate the names of random fruits.

As wrote in the README, it works in both the front-end and backend (Node.js) environment.
I'll write an example implementation in React.

import React from "react";
import "./styles.css";
import getRandomFruitsName from "random-fruits-name";

export default function App() {
  return (
    <div className="App">
      <h1>Random Fruits name with React example</h1>
      <h2>This npm package of generate the names of random fruits.</h2>
      <p>{getRandomFruitsName() /* English is default language */}</p>
Enter fullscreen mode Exit fullscreen mode

I've put the same code on CodeSandbox. You can see it in action here.

random-fruits-name-with-react-example - CodeSandbox

At first it was a really simple npm package that just returned the names of fruits in English.
One day, however, a developer wrote a PR for Spanish, and that's when we started to add multi-language support, little by little.

Adding Spanish Language #2(random-fruits-name.js)

Currently, Support four languages.

  • English
  • Spanish
  • Japanese
  • Portuguese

I haven't done that many commits in the open source community.
But I've always wanted to do it.

So I'm happy and very excited about this PR.
This is because they added support for multiple languages, a nice feature I hadn't initially thought of.
In this way, I also hope to contribute by sending PR to someone else's open source project.
(Oh, and by the way, last year was my first time attending Hacktoberfest, and I got a t-shirt!)

And I also welcome PR for random-fruits-name.js.
I hope that more language support will be added to this simple npm package :)

Latest comments (3)

cashoefman profile image
Cas Hoefman

There! Added Dutch for you!

shinshin86 profile image
Yuki Shindo

Thank you for the PR!
I've merged Dutch lang support and released it to npm!