npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@frenglish/utils

v1.0.58

Published

Utils for Frenglish translation service

Readme

Frenglish Utils

                                     _____                     _ _     _            _ 
                                    |  ___| __ ___ _ __   __ _| (_)___| |__    __ _(_)
                                    | |_ | '__/ _ \ '_ \ / _` | | / __| '_ \  / _` | |
                                    |  _|| | |  __/ | | | (_| | | \__ \ | | || (_| | |
                                    |_|  |_|  \___|_| |_|\__, |_|_|___/_| |_(_)__,_|_|
                                                         |___/                      

A shared utilities package for the Frenglish SDK and CLI tools. This package provides common helper functions and types used across the Frenglish ecosystem.

Note: This package is primarily used internally by the Frenglish SDK and CLI. While it can be used directly, it's recommended to use the main SDK package for most use cases.

Installation

npm install @frenglish/utils

Features

File Management

  1. findLanguageFilesToTranslate

    • Description: Finds language files in a directory structure by detecting language codes in paths
    • Parameters:
      • basePath: string - Base directory to start searching from
      • originLanguage: string - Source language code
      • supportedLanguages: string[] - Array of supported language codes
      • supportedFileTypes: string[] - Array of supported file extensions
      • excludePath: string[] (optional) - Paths to exclude from search
    • Returns: Promise<Map<string, string[]>> - Map of language codes to file paths
  2. readFiles

    • Description: Reads multiple files and returns their contents
    • Parameters:
      • files: string[] - Array of file paths to read
    • Returns: Promise<Array<{ fileId: string; content: string }>>
  3. validateFiles

    • Description: Validates file contents to ensure they meet basic requirements
    • Parameters:
      • files: Array<{ fileId: string; content: string }> - Array of files to validate
    • Returns: boolean
  4. getRelativePath

    • Description: Gets the relative path of a file, handling language-specific paths
    • Parameters:
      • basePath: string - Base directory
      • filePath: string - File path to process
      • supportedLanguages: string[] - Array of supported language codes
      • excludePaths: string[] (optional) - Paths to exclude
    • Returns: Promise<string | undefined>

Configuration Management

  1. parsePartialConfig
    • Description: Parses configuration from JSON string or file
    • Parameters:
      • partialConfig: string | Partial | undefined - Configuration to parse
    • Returns: Promise<Partial | undefined>

Types

The package exports several TypeScript types used across the Frenglish ecosystem. This package allows you to understand all the Frenglish types for each SDK function:

Translation Types

  • TranslationResponse - Response object containing translated content and metadata
  • TranslationStatus - Enum representing the current status of a translation (e.g., COMPLETED, IN_PROGRESS)
  • CompletedTranslationResponse - Response object for completed translations
  • FlatJSON - Type for flattened JSON structures used in translations

Configuration Types

  • Configuration - Complete configuration object for a Frenglish project
  • PartialConfiguration - Type for partial configuration updates

Project Types

  • Project - Complete project information including settings and metadata
  • ProjectResponse - Response object containing project data

File Types

  • FileContentWithLanguage - Type for file content with associated language information

Best Practices

  1. File Path Handling

    • Use the provided utility functions for consistent path handling
    • Always normalize paths using the provided functions
    • Handle language-specific paths appropriately
  2. Configuration

    • Use the type-safe configuration interfaces
    • Validate configurations before use
    • Handle partial configurations appropriately
  3. Error Handling

    • Always check return values for undefined/null
    • Handle file reading errors gracefully
    • Validate file contents before processing

Support

For more information, visit https://www.frenglish.ai or email us at [email protected]