DEV Community

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

Posted on

1 2

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>
      <p>{getRandomFruitsName("en")}</p>
      <p>{getRandomFruitsName("es")}</p>
      <p>{getRandomFruitsName("ja")}</p>
      <p>{getRandomFruitsName("pt")}</p>
    </div>
  );
}
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 :)

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (2)

Collapse
 
cashoefman profile image
Cas Hoefman

There! Added Dutch for you!

Collapse
 
shinshin86 profile image
Yuki Shindo

Thank you for the PR!
I've merged Dutch lang support and released it to npm!
npmjs.com/package/random-fruits-name

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay