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

podb

v0.0.14

Published

[![Build Status](https://travis-ci.com/vharitonsky/podb.svg?branch=master)](https://travis-ci.com/vharitonsky/podb)

Downloads

33

Readme

Build Status

What is this ?

SQL interface for po(gettext) files.

Motivation

Use po file as a database. Can be useful for cli tools, UI interfaces, data exploration, also for fun.

Supported SQL

SELECT
UPDATE
SET
WHERE
AND
OR
NOT
COUNT
LIKE
LIMIT

Available columns

msgid, msgstr, msgstr[0-9], msgctxt, msgid_plural

Examples

As database:

import {PoDb} from 'podb';
// open current directory as db
const db = new PoDb('.'); 
 // catalog is a table points to catalog.po in './'
const messages = db.execute("select count(1) from catalog")
console.log(messages); // 42

As table:

import * as fs from 'fs'
import {PoTable} from 'podb';
// open in memory data as a table
const table = new PoTable(fs.readFileSync('catalog.po').toString()); 
// table name is irrelevant in select clauses except 'table' is a reserved word
// get all untranslated records
table.execute("select * from t where not msgstr")); 
// [{ msgid: ' в категории %s',
//     msgctxt: null,
//     references: [ 'myproj/lib/title.py:959' ],
//     msgid_plural: null,
//     msgstr: [ '' ],
//     comments: [],
//     extractedComments: [],
//     flags: { 'python-format': true },
//     obsolete: false,
//     nplurals: 3 },
//  ....
//]

Compound statements

// get all untranslated plural strings
table.execute("select * from t where msgid_plural and not msgstr")); 

LIKE

table.execute("select * from t where msgstr like 'пошук'")
// [ { msgid: ' Продажа, поиск, поставщики и магазины, все цены',
//     msgctxt: null,
//     references: [ 'myproj/lib/title.py:1014' ],
//     msgid_plural: null,
//     msgstr: [ ' Продаж, пошук, постачальники та магазини, всі ціни' ],
//     comments: [],
//     extractedComments: [],
//     flags: {},
//     obsolete: false,
//     nplurals: 3 },

Advanced LIKE for case insensitive search

table.execute("select * from t where msgstr like '/продаж/i'")
// [ { msgid: ' Продажа, поиск, поставщики и магазины, все цены',
//     msgctxt: null,
//     references: [ 'myproj/lib/title.py:1014' ],
//     msgid_plural: null,
//     msgstr: [ ' Продаж, пошук, постачальники та магазини, всі ціни' ],
//     comments: [],
//     extractedComments: [],
//     flags: {},
//     obsolete: false,
//     nplurals: 3 },
//     ...
//     ]

LIMIT/OFFSET

table.execute("select * from t limit 10,20"); // offset 10 limit 20

UPDATE

table.getTableData()
// msgid ""
// msgstr ""
// "Content-Type: text/plain; charset=utf-8\n"
// "Plural-Forms: nplurals=2; plural=(n!=1);\n"

// #: tests/fixtures/checkTest/check-trans-exist.js:2
// #: tests/fixtures/checkTest/check-trans-exist.js:3
// msgid "test"
// msgstr ""

table.execute("update simple set msgstr='value' where msgid='test'"); // 1
table.getTableData();

// msgid ""
// msgstr ""
// "Content-Type: text/plain; charset=utf-8\n"
// "Plural-Forms: nplurals=2; plural=(n!=1);\n"

// #: tests/fixtures/checkTest/check-trans-exist.js:2
// #: tests/fixtures/checkTest/check-trans-exist.js:3
// msgid "test"
// msgstr "value"

Or as db

 // sync to file
db.execute("update simple set msgstr='value' where msgid='test'", true);

Plurals

In case message has multiple plural forms, all operations must be made by specifying an additional index in the column name i.e:

msgstr2

As indexes start with 0, this refers to third form of the message, otherwise it will be treated like singular.

// get all items with second form equals to 'xxx'
table.execute("select count(1) from t where msgstr1='xxx'")

// update an item and set it's first form to 'yyy'
table.execute("update t set msgstr0='yyy' where msgstr1='xxx'")

Plans

  • IN operator
  • ORDER operator
  • handy functions(LOWER, UPPER)

Kudos

rubenv for excelent pofile library.

godmodelabs for handy flora-sql-parser