Skip to content

Commit

Permalink
fix: direct method translator
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacdarcilla committed Sep 25, 2023
1 parent 3b828bd commit 9440539
Show file tree
Hide file tree
Showing 16 changed files with 85 additions and 5 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ const result = translate('maganda', Script.BUHID);
or directly use the translator methods base on the script you want:

```js
import toBaybayin from 'filipino-script-translator/scripts/baybayin';
import toBuhid from 'filipino-script-translator/scripts/buhid';
import toTagbanwa from 'filipino-script-translator/scripts/tagbanwa';
import toHanunoo from 'filipino-script-translator/scripts/hanunoo';
import { toBaybayin, toBuhid, toHanunoo, toTagbanwa } from 'filipino-script-translator';

const result = toBaybayin('maganda');
// Output: ᜋᜄᜈ᜔ᜇ
Expand Down
5 changes: 5 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import toBaybayin from './scripts/baybayin';
import toBuhid from './scripts/buhid';
import toHanunoo from './scripts/hanunoo';
import toTagbanwa from './scripts/tagbanwa';
export declare enum Script {
BAYBAYIN = "baybayin",
HANUNOO = "hanunoo",
Expand All @@ -12,3 +16,4 @@ export declare enum Script {
* @returns string
*/
export declare const translate: (text: string, script?: Script) => string;
export { toBaybayin, toBuhid, toHanunoo, toTagbanwa };
6 changes: 5 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.translate = exports.Script = void 0;
exports.toTagbanwa = exports.toHanunoo = exports.toBuhid = exports.toBaybayin = exports.translate = exports.Script = void 0;
const baybayin_1 = __importDefault(require("./scripts/baybayin"));
exports.toBaybayin = baybayin_1.default;
const buhid_1 = __importDefault(require("./scripts/buhid"));
exports.toBuhid = buhid_1.default;
const hanunoo_1 = __importDefault(require("./scripts/hanunoo"));
exports.toHanunoo = hanunoo_1.default;
const tagbanwa_1 = __importDefault(require("./scripts/tagbanwa"));
exports.toTagbanwa = tagbanwa_1.default;
var Script;
(function (Script) {
Script["BAYBAYIN"] = "baybayin";
Expand Down
6 changes: 6 additions & 0 deletions lib/scripts/baybayin.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
/**
* Translate text to Baybayin.
*
* @param text
* @returns string
*/
export default function toBaybayin(text: string): string;
6 changes: 6 additions & 0 deletions lib/scripts/baybayin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Translate text to Baybayin.
*
* @param text
* @returns string
*/
function toBaybayin(text) {
const replacements = [
[/e/g, 'i'],
Expand Down
6 changes: 6 additions & 0 deletions lib/scripts/buhid.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
/**
* Translate text to Buhid.
*
* @param text
* @returns string
*/
export default function toBuhid(text: string): string;
6 changes: 6 additions & 0 deletions lib/scripts/buhid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Translate text to Buhid.
*
* @param text
* @returns string
*/
function toBuhid(text) {
const replacements = [
[/o/g, 'u'],
Expand Down
6 changes: 6 additions & 0 deletions lib/scripts/hanunoo.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
/**
* Translate text to Hanunoo.
*
* @param text
* @returns string
*/
export default function toHanunoo(text: string): string;
6 changes: 6 additions & 0 deletions lib/scripts/hanunoo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Translate text to Hanunoo.
*
* @param text
* @returns string
*/
function toHanunoo(text) {
const replacements = [
[/o/g, 'u'],
Expand Down
6 changes: 6 additions & 0 deletions lib/scripts/tagbanwa.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
/**
* Translate text to Tagbanwa.
*
* @param text
* @returns string
*/
export default function toTagbanwa(text: string): string;
6 changes: 6 additions & 0 deletions lib/scripts/tagbanwa.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Translate text to Tagbanwa.
*
* @param text
* @returns string
*/
function toTagbanwa(text) {
const replacements = [
[/o/g, 'u'],
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ export const translate = (
const scriptConverter = scriptConverters[script] || toBaybayin;
return scriptConverter(text);
};

export { toBaybayin, toBuhid, toHanunoo, toTagbanwa };
6 changes: 6 additions & 0 deletions src/scripts/baybayin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Translate text to Baybayin.
*
* @param text
* @returns string
*/
export default function toBaybayin(text: string): string {
const replacements: [RegExp, string][] = [
[/e/g, 'i'],
Expand Down
6 changes: 6 additions & 0 deletions src/scripts/buhid.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Translate text to Buhid.
*
* @param text
* @returns string
*/
export default function toBuhid(text: string): string {
const replacements: [RegExp, string][] = [
[/o/g, 'u'],
Expand Down
6 changes: 6 additions & 0 deletions src/scripts/hanunoo.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Translate text to Hanunoo.
*
* @param text
* @returns string
*/
export default function toHanunoo(text: string): string {
const replacements: [RegExp, string][] = [
[/o/g, 'u'],
Expand Down
6 changes: 6 additions & 0 deletions src/scripts/tagbanwa.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Translate text to Tagbanwa.
*
* @param text
* @returns string
*/
export default function toTagbanwa(text: string): string {
const replacements: [RegExp, string][] = [
[/o/g, 'u'],
Expand Down

0 comments on commit 9440539

Please sign in to comment.