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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yamato-daiwa/es-extensions-localization-japanese

v1.6.5

Published

Japanese localization for @yamato-daiwa/es-extensions package.

Downloads

23

Readme

@yamato-daiwa/es-extensionsの日本語化

導入

@yamato-daiwa/es-extensions-localization-japanese は、@yamato-daiwa/es-extensions(以下YDEE) にピア依存関係(peer dependency)を持つ日本語化ライブラリであり、 マイナーバージョンまで一致している YDEE で利用可能だ。

例えばバージョン1.5.0は、YDEE のバージョン1.5.0~1.5.? で使えるが、バージョン1.6.0以上では使用不可。

npm i @yamato-daiwa/es-extensions-localization-japanese @yamato-daiwa/es-extensions -E

方法論

此のパッケージでは日本語の処理負荷の低減に重々配慮しているが、出力用の JavaScript コードを増やした為、ブラウザー環境で実行されるスクリプトでは多少の悪影響を及ぼす恐れがある。

此のため使用頻度が低いか全く無い機能を含め、全てを日本語化してしまう事は非効率なので推奨されず、特にブラウザー専用のコードの場合は尚更だ。

上記を考慮した結果、現在 YDEE の完全な日本語化機能は提供されていない。

現時点で日本語化可能な機能、及び日本語化の方法については、以下をご参照いただきたい。

日本語化可能な機能

RawObjectDataProcessorクラス

RawObjectDataProcessor クラスは process メソッド を呼び出すことで日本語化出来、アプリケーションが実行されている限り、間接的ではあるが日本語化への対応が可能だ。

但し此の方法には、 RawObjectDataProcessorLocalization__Japanese という日本語化用オブジェクトが必要だ。

process メソッドの実行で日本語化する場合、次の様に第3引数の localization プロパティで RawObjectDataProcessorLocalization__Japanese を指定すればよい。

import { RawObjectDataProcessor } from "@yamato-daiwa/es-extensions";
import { RawObjectDataProcessorLocalization__Japanese } from "@yamato-daiwa/es-extensions-localization-japanese";

type User = {
  ID: string;
  familyName: string;
  givenName: string;
};


const processingResult: RawObjectDataProcessor.ProcessingResult<User> = RawObjectDataProcessor.process(
  rawData, 
  {
    nameForLogging: "User",
    subtype: RawObjectDataProcessor.ObjectSubtypes.fixedKeyAndValuePairsObject,
    properties: { /* */ }
  },
  { localization: RawObjectDataProcessorLocalization__Japanese }
);

アプリケーションの実行中 RawObjectDataProcessor を有効にしておきたい場合は、次のようにsetDefaultLocalization を呼び出す。

import { RawObjectDataProcessor } from "@yamato-daiwa/es-extensions";
import { RawObjectDataProcessorLocalization__Japanese } from "@yamato-daiwa/es-extensions-localization-japanese";


RawObjectDataProcessor.setDefaultLocalization(RawObjectDataProcessorLocalization__Japanese);

Loggerファサードの日本語化

LoggerLocalization__Japanese オブジェクトは Logger クラスに属する文字列を日本語化するが、これらの総数は少ない。 各エラーメッセージは別途日本語化する必要があり、YDEE のエラークラスの日本語化方法については以下の通りだ。

import { Logger } from "@yamato-daiwa/es-extensions";
import LoggerLocalization__Japanese from "@yamato-daiwa/es-extensions-localization-japanese";


Logger.setLocalization(LoggerLocalization__Japanese);

エラークラスの日本語化

特定のエラーのクラスの日本語化オブジェクト名は、下記の命名規則に従っている。

[ エラークラス名 ]+Lozalization__Japanese

例えば AlgorithmMismatchError エラーの日本語化オブジェクトは、AlgorithmMismatchErrorLocalization__Japanese という名前になる。

全てのエラークラス名は、@ydee公式説明書 で確認可能だ。

インポートされた日本語化オブジェクトは、適切なエラークラスの公開静的フィールド localization に割り当てる必要が有る。

例えば AlgorithmMismatchError の場合は、

import { AlgorithmMismatchError } from "@yamato-daiwa/es-extensions";
import { AlgorithmMismatchErrorLocalization__Japanese } from "@yamato-daiwa/es-extensions-localization-japanese";

AlgorithmMismatchError.localization = AlgorithmMismatchErrorLocalization__Japanese;

の様に記述して割り当てる。

追加機能

定数・列挙

日時(曜日、月)

JapaneseDaysOfWeek列挙

曜日の名前を含む列挙。 キーはDaysOfWeek 列挙のキーと一致。

console.log(JapaneseDaysOfWeek.sunday); // -> "日曜日"
console.log(JapaneseDaysOfWeek.monday); // -> "月曜日"
console.log(JapaneseDaysOfWeek.tuesday); // -> "火曜日"
console.log(JapaneseDaysOfWeek.wednesday); // -> "水曜日"
console.log(JapaneseDaysOfWeek.thursday); // -> "木曜日"
console.log(JapaneseDaysOfWeek.friday); // -> "金曜日"
console.log(JapaneseDaysOfWeek.saturday); // -> "土曜日"
AbbreviatedJapaneseDaysOfWeek列挙

各曜日の頭文字を含む列挙。 キーはDaysOfWeek 列挙のキーと一致。

console.log(AbbreviatedJapaneseDaysOfWeek.sunday); // -> "日"
console.log(AbbreviatedJapaneseDaysOfWeek.monday); // -> "月"
console.log(AbbreviatedJapaneseDaysOfWeek.tuesday); // -> "火"
console.log(AbbreviatedJapaneseDaysOfWeek.wednesday); // -> "水"
console.log(AbbreviatedJapaneseDaysOfWeek.thursday); // -> "木"
console.log(AbbreviatedJapaneseDaysOfWeek.friday); // -> "金"
console.log(AbbreviatedJapaneseDaysOfWeek.saturday); // -> "土"
JapaneseMonthsNames列挙

日本語でアラビア数字を用いる一般月名。 キーはMonthsNames 列挙のキーと一致。

console.log(JapaneseMonthsNames.january); // -> "1月"
console.log(JapaneseMonthsNames.february); // -> "2月"
console.log(JapaneseMonthsNames.march); // -> "3月"
console.log(JapaneseMonthsNames.april); // -> "4月"
console.log(JapaneseMonthsNames.may); // -> "5月"
console.log(JapaneseMonthsNames.june); // -> "6月"
console.log(JapaneseMonthsNames.july); // -> "7月"
console.log(JapaneseMonthsNames.august); // -> "8月"
console.log(JapaneseMonthsNames.september); // -> "9月"
console.log(JapaneseMonthsNames.october); // -> "10月"
console.log(JapaneseMonthsNames.november); // -> "11月"
console.log(JapaneseMonthsNames.december); // -> "12月"
JapaneseTraditionalMonthsNames列挙

日本語の伝統的な月名である旧暦の月名。 キーはMonthsNames 列挙のキーと一致。

console.log(JapaneseTraditionalMonthsNames.january); // -> "睦月"
console.log(JapaneseTraditionalMonthsNames.february); // -> "如月"
console.log(JapaneseTraditionalMonthsNames.march); // -> "弥生"
console.log(JapaneseTraditionalMonthsNames.april); // -> "卯月"
console.log(JapaneseTraditionalMonthsNames.may); // -> "皐月"
console.log(JapaneseTraditionalMonthsNames.june); // -> "水無月"
console.log(JapaneseTraditionalMonthsNames.july); // -> "文月"
console.log(JapaneseTraditionalMonthsNames.august); // -> "葉月"
console.log(JapaneseTraditionalMonthsNames.september); // -> "長月"
console.log(JapaneseTraditionalMonthsNames.october); // -> "神無月"
console.log(JapaneseTraditionalMonthsNames.november); // -> "霜月"
console.log(JapaneseTraditionalMonthsNames.december); // -> "師走"