index int64 0 0 | repo_id stringlengths 16 181 | file_path stringlengths 28 270 | content stringlengths 1 11.6M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | petrpan-code/lingui/js-lingui/packages/loader/test | petrpan-code/lingui/js-lingui/packages/loader/test/po-format/entrypoint.js | export async function load() {
return import("@lingui/loader!./locale/en.po")
}
| 5,100 |
0 | petrpan-code/lingui/js-lingui/packages/loader/test/po-format | petrpan-code/lingui/js-lingui/packages/loader/test/po-format/locale/en.po | msgid "Hello World"
msgstr "Hello World"
msgid "My name is {name}"
msgstr "My name is {name}"
| 5,101 |
0 | petrpan-code/lingui/js-lingui/packages/loader/test/po-format | petrpan-code/lingui/js-lingui/packages/loader/test/po-format/locale/messages.pot | msgid "Hello World"
msgstr ""
msgid "My name is {name}"
msgstr ""
msgid "String from template"
msgstr ""
| 5,102 |
0 | petrpan-code/lingui/js-lingui/packages/loader/test | petrpan-code/lingui/js-lingui/packages/loader/test/relative-catalog-path/.linguirc | {
"locales": ["en"],
"catalogs": [{
"path": "./locale/{locale}"
}],
"fallbackLocales": {
"default": "en"
},
"format": "po"
}
| 5,103 |
0 | petrpan-code/lingui/js-lingui/packages/loader/test | petrpan-code/lingui/js-lingui/packages/loader/test/relative-catalog-path/entrypoint.js | export async function load() {
return import("@lingui/loader!./locale/en.po")
}
| 5,104 |
0 | petrpan-code/lingui/js-lingui/packages/loader/test/relative-catalog-path | petrpan-code/lingui/js-lingui/packages/loader/test/relative-catalog-path/locale/en.po | msgid "Hello World"
msgstr "Hello World"
msgid "My name is {name}"
msgstr "My name is {name}"
| 5,105 |
0 | petrpan-code/lingui/js-lingui/packages/loader/test/relative-catalog-path | petrpan-code/lingui/js-lingui/packages/loader/test/relative-catalog-path/locale/messages.pot | msgid "Hello World"
msgstr ""
msgid "My name is {name}"
msgstr ""
msgid "String from template"
msgstr ""
| 5,106 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/macro/CHANGELOG.md | # Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [4.5.0](https://github.com/lingui/js-lingui/compare/v4.4.2...v4.5.0) (2023-09-14)
**Note:** Version bump only for package @lingui/macro
## [4.4.2](ht... | 5,107 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/macro/README.md | [![License][badge-license]][license]
[![Version][badge-version]][package]
[![Downloads][badge-downloads]][package]
[![Babel Macro][badge-macro]][linguijs]
# @lingui/macro
> [Babel Macros](https://github.com/kentcdodds/babel-plugin-macros) which
> transforms tagged template literals and JSX components to ICU MessageFo... | 5,108 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/macro/build.config.ts | import { defineBuildConfig } from "unbuild"
export default defineBuildConfig({
declaration: false,
})
| 5,109 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/macro/global.d.ts | // read more about this file here
// https://github.com/lingui/js-lingui/issues/936
// @ts-ignore
declare module "@lingui/macro" {
import type { MessageDescriptor, I18n } from "@lingui/core"
type MacroMessageDescriptor = (
| {
id: string
message?: string
}
| {
id?: string
... | 5,110 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/macro/index.d.ts | // eslint-disable-next-line import/no-extraneous-dependencies
import type { ReactNode, VFC, FC } from "react"
import type { I18n, MessageDescriptor } from "@lingui/core"
import type { TransRenderCallbackOrComponent } from "@lingui/react"
export type ChoiceOptions = {
/** Offset of value when calculating plural forms... | 5,111 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/macro/package.json | {
"name": "@lingui/macro",
"version": "4.5.0",
"description": "Macro for generating messages in ICU MessageFormat syntax",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./index.d.ts",
"sideEffects": false,
"author": {
"name": "Tomáš Ehrlich",
"email": "tomas.ehrlich@gmail.c... | 5,112 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/macro/tsconfig.json | {
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": [
"ES2019.Array"
],
"strict": true,
"strictNullChecks": false
}
}
| 5,113 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/__typetests__/index.test-d.tsx | import { expectType } from "tsd"
import type { MessageDescriptor, I18n } from "@lingui/core"
import {
t,
defineMessage,
msg,
plural,
selectOrdinal,
select,
Trans,
Plural,
Select,
SelectOrdinal,
} from "../index"
// eslint-disable-next-line import/no-extraneous-dependencies
import React from "react"... | 5,114 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/__typetests__/tsconfig.json | {
"compilerOptions": {
"jsx": "react",
"esModuleInterop": true,
"skipLibCheck": true
},
"paths": {}
}
| 5,115 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/constants.ts | export const ID = "id"
export const MESSAGE = "message"
export const COMMENT = "comment"
export const EXTRACT_MARK = "i18n"
export const CONTEXT = "context"
| 5,116 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/icu.test.ts | import ICUMessageFormat, { Token } from "./icu"
import { Identifier } from "@babel/types"
describe("ICU MessageFormat", function () {
it("should collect text message", function () {
const messageFormat = new ICUMessageFormat()
const tokens: Token[] = [
{
type: "text",
value: "Hello Worl... | 5,117 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/icu.ts | import {
Expression,
isJSXEmptyExpression,
JSXElement,
Node,
} from "@babel/types"
const metaOptions = ["id", "comment", "props"]
const escapedMetaOptionsRe = new RegExp(`^_(${metaOptions.join("|")})$`)
export type ParsedResult = {
message: string
values?: Record<string, Expression>
jsxElements?: Recor... | 5,118 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/index.ts | import { createMacro, MacroParams } from "babel-plugin-macros"
import { getConfig as loadConfig, LinguiConfigNormalized } from "@lingui/conf"
import MacroJS from "./macroJs"
import MacroJSX from "./macroJsx"
import { NodePath } from "@babel/traverse"
import {
ImportDeclaration,
Identifier,
isImportSpecifier,
i... | 5,119 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/macroJs.test.ts | import { parseExpression } from "@babel/parser"
import * as types from "@babel/types"
import MacroJs from "./macroJs"
import { CallExpression } from "@babel/types"
function createMacro() {
return new MacroJs(
{ types },
{
i18nImportName: "i18n",
stripNonEssentialProps: false,
nameMap: new M... | 5,120 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/macroJs.ts | import * as babelTypes from "@babel/types"
import {
CallExpression,
Expression,
Identifier,
isObjectProperty,
Node,
ObjectExpression,
ObjectProperty,
SourceLocation,
StringLiteral,
TemplateLiteral,
} from "@babel/types"
import { NodePath } from "@babel/traverse"
import ICUMessageFormat, {
ArgToke... | 5,121 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/macroJsx.test.ts | import * as types from "@babel/types"
import MacroJSX, { normalizeWhitespace } from "./macroJsx"
import { transformSync } from "@babel/core"
import type { NodePath } from "@babel/traverse"
import type { JSXElement } from "@babel/types"
const parseExpression = (expression: string) => {
let path: NodePath<JSXElement>
... | 5,122 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/macroJsx.ts | import * as babelTypes from "@babel/types"
import {
ConditionalExpression,
Expression,
JSXAttribute,
JSXElement,
JSXExpressionContainer,
JSXIdentifier,
JSXSpreadAttribute,
Literal,
Node,
StringLiteral,
TemplateLiteral,
} from "@babel/types"
import { NodePath } from "@babel/traverse"
import ICUMes... | 5,123 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/src/utils.ts | export const makeCounter =
(index = 0) =>
() =>
index++
| 5,124 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/index.ts | import fs from "fs"
import path from "path"
import {
PluginObj,
transformFileSync,
TransformOptions,
transformSync,
} from "@babel/core"
import prettier from "prettier"
import { LinguiMacroOpts } from "../src/index"
import {
JSXAttribute,
jsxExpressionContainer,
JSXIdentifier,
stringLiteral,
} from "@ba... | 5,125 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/js-defineMessage.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
name: "defineMessage should support template literal",
input: `
import { defineMessage } from '@lingui/macro';
const message = defineMessage\`Message\`
`,
expected: `
const message =
/*i18n*/
... | 5,126 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/js-plural.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
name: "Macro is used in expression assignment",
input: `
import { plural } from '@lingui/macro'
const a = plural(count, {
"one": \`# book\`,
other: "# books"
});
`,
expected: `
impor... | 5,127 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/js-select.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
name: "Nested macros",
input: `
import { select, plural } from '@lingui/macro'
select(gender, {
"male": plural(numOfGuests, {
one: "He invites one guest",
other: "He invites # guests"
... | 5,128 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/js-selectOrdinal.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
input: `
import { t, selectOrdinal } from '@lingui/macro'
t\`This is my \${selectOrdinal(count, {
one: "#st",
"two": \`#nd\`,
other: ("#rd")
})} cat\`
`,
expected: `
import { ... | 5,129 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/js-t.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
name: "Macro is used in expression assignment",
input: `
import { t } from '@lingui/macro';
const a = t\`Expression assignment\`;
`,
expected: `
import { i18n } from "@lingui/core";
const a = i18n._(
... | 5,130 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/jsx-plural.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
input: `
import { Plural } from '@lingui/macro';
<Plural
value={count}
offset="1"
_0="Zero items"
few={\`\${count} items\`}
other={<a href="/more">A lot of them</a>}
/>;
... | 5,131 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/jsx-select.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
stripId: true,
input: `
import { Select } from '@lingui/macro';
<Select
value={count}
_male="He"
_female={\`She\`}
other={<strong>Other</strong>}
/>;
`,
expected: `
... | 5,132 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/jsx-selectOrdinal.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
stripId: true,
input: `
import { Trans, SelectOrdinal } from '@lingui/macro';
<Trans>
This is my <SelectOrdinal
value={count}
one="#st"
two={\`#nd\`}
other={<strong>#rd</... | 5,133 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/jsx-trans.ts | import { TestCase } from "./index"
const cases: TestCase[] = [
{
name: "Generate ID from message",
input: `
import { Trans } from '@lingui/macro';
<Trans>Hello World</Trans>;
`,
expected: `
import { Trans } from "@lingui/react";
<Trans id={"mY42CM"} message={"Hello W... | 5,134 |
0 | petrpan-code/lingui/js-lingui/packages/macro | petrpan-code/lingui/js-lingui/packages/macro/test/lingui.config.js | module.exports = {
locales: ["en"],
}
| 5,135 |
0 | petrpan-code/lingui/js-lingui/packages/macro/test | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures/js-t-continuation-character.expected.js | import { i18n } from "@lingui/core"
i18n._(
/*i18n*/
{
id: "LBYoFK",
message: "Multiline with continuation",
}
)
| 5,136 |
0 | petrpan-code/lingui/js-lingui/packages/macro/test | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures/js-t-continuation-character.js | import { t } from '@lingui/macro'
t`Multiline\
with continuation`
| 5,137 |
0 | petrpan-code/lingui/js-lingui/packages/macro/test | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures/jsx-plural-select-nested.expected.js | import { Trans } from "@lingui/react"
;<Trans
id={"n0a/bN"}
message={
"{genderOfHost, select, female {{numGuests, plural, offset:1 =0 {{host} does not give a party.} =1 {{host} invites {guest} to her party.} =2 {{host} invites {guest} and one other person to her party.} other {{host} invites {guest} and # other... | 5,138 |
0 | petrpan-code/lingui/js-lingui/packages/macro/test | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures/jsx-plural-select-nested.js | import { Select, Plural } from '@lingui/macro';
<Select
value={genderOfHost}
_female={
<Plural
value={numGuests}
offset="1"
_0={`${host} does not give a party.`}
_1={`${host} invites ${guest} to her party.`}
_2={`${host} invites ${guest} and one other person to her party.`}
... | 5,139 |
0 | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures/js-t-var/.babelrc | {
"presets": ["@babel/preset-env"],
"plugins": ["@babel/plugin-syntax-jsx", "macros"]
}
| 5,140 |
0 | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures/js-t-var/js-t-var.expected.js | "use strict"
var _core = require("@lingui/core")
function scoped(foo) {
if (foo) {
var bar = 50
_core.i18n._(
/*i18n*/
{
id: "EvVtyn",
message: "This is bar {bar}",
values: {
bar: bar,
},
}
)
} else {
var _bar = 10
_core.i18n._(
... | 5,141 |
0 | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures | petrpan-code/lingui/js-lingui/packages/macro/test/fixtures/js-t-var/js-t-var.js | import { t } from '@lingui/macro'
function scoped (foo) {
if (foo) {
const bar = 50
t`This is bar ${bar}`
} else {
const bar = 10
t`This is a different bar ${bar}`
}
}
| 5,142 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/message-utils/CHANGELOG.md | # Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [4.5.0](https://github.com/lingui/js-lingui/compare/v4.4.2...v4.5.0) (2023-09-14)
**Note:** Version bump only for package @lingui/message-utils
## [4... | 5,143 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/message-utils/README.md | [![License][badge-license]][license]
[![Version][badge-version]][package]
[![Downloads][badge-downloads]][package]
# @lingui/message-utils
> Internal package. You probably don't need to use it directly.
`@lingui/message-utils` is part of [LinguiJS][linguijs]. See the [documentation][documentation]
for all informatio... | 5,144 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/message-utils/compileMessage.js | /**
* this file is a workaround for older runtimes
* such as React Native or Jest 27 which is not
* support package.json exports field
**/
module.exports = require("./dist/compileMessage.cjs")
| 5,145 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/message-utils/generateMessageId.js | /**
* this file is a workaround for older runtimes
* such as React Native or Jest 27 which is not
* support package.json exports field
**/
module.exports = require("./dist/generateMessageId.cjs")
| 5,146 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/message-utils/package.json | {
"name": "@lingui/message-utils",
"version": "4.5.0",
"license": "MIT",
"keywords": [],
"sideEffects": false,
"exports": {
"./generateMessageId": {
"require": {
"types": "./dist/generateMessageId.d.cts",
"default": "./dist/generateMessageId.cjs"
},
"import": {
... | 5,147 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/message-utils/tsconfig.json | {
"extends": "../../tsconfig.json",
"compilerOptions": {
"lib": [
"ES2019.Array"
],
"strict": true,
"strictNullChecks": false
}
}
| 5,148 |
0 | petrpan-code/lingui/js-lingui/packages/message-utils | petrpan-code/lingui/js-lingui/packages/message-utils/src/compileMessage.test.ts | import { mockConsole } from "@lingui/jest-mocks"
import { compileMessage } from "./compileMessage"
describe("compileMessage", () => {
it("should handle an error if message has syntax errors", () => {
mockConsole((console) => {
expect(compileMessage("Invalid {message")).toEqual("Invalid {message")
exp... | 5,149 |
0 | petrpan-code/lingui/js-lingui/packages/message-utils | petrpan-code/lingui/js-lingui/packages/message-utils/src/compileMessage.ts | import { Content, parse, Token } from "@messageformat/parser"
export type CompiledIcuChoices = Record<string, CompiledMessage> & {
offset: number | undefined
}
export type CompiledMessageToken =
| string
| [name: string, type?: string, format?: null | string | CompiledIcuChoices]
export type CompiledMessage = ... | 5,150 |
0 | petrpan-code/lingui/js-lingui/packages/message-utils | petrpan-code/lingui/js-lingui/packages/message-utils/src/generateMessageId.test.ts | import { generateMessageId } from "./generateMessageId"
describe("generateMessageId", () => {
it("Should generate an id for a message", () => {
expect(generateMessageId("my message")).toMatchInlineSnapshot(`vQhkQx`)
})
it("Should generate different id when context is provided", () => {
const withContext... | 5,151 |
0 | petrpan-code/lingui/js-lingui/packages/message-utils | petrpan-code/lingui/js-lingui/packages/message-utils/src/generateMessageId.ts | import { sha256 } from "js-sha256"
const UNIT_SEPARATOR = "\u001F"
export function generateMessageId(msg: string, context = "") {
return hexToBase64(sha256(msg + UNIT_SEPARATOR + (context || ""))).slice(0, 6)
}
function hexToBase64(hexStr: string) {
let base64 = ""
for (let i = 0; i < hexStr.length; i++) {
... | 5,152 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/react/.eslintrc | {
"extends": ["../../.eslintrc", "plugin:react/recommended", "plugin:react-hooks/recommended"],
"settings": {
"react": {
"version": "detect" // "detect" automatically picks the version of React that is installed
}
},
"rules": {
"react/prop-types": "off",
"react/display-name": "off"
}
}
| 5,153 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/react/CHANGELOG.md | # Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [4.5.0](https://github.com/lingui/js-lingui/compare/v4.4.2...v4.5.0) (2023-09-14)
### Features
- **react:** export react server sub-entry ([#1762](ht... | 5,154 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/react/README.md | [![License][badge-license]][license]
[![Version][badge-version]][package]
[![Downloads][badge-downloads]][package]
# @lingui/react
> React components for internationalization
`@lingui/react` is part of [LinguiJS][linguijs]. See the [documentation][documentation] for all information, tutorials and examples.
## Insta... | 5,155 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/react/package.json | {
"name": "@lingui/react",
"version": "4.5.0",
"sideEffects": false,
"description": "React components for translations",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"author": {
"name": "Tomáš Ehrlich",
"email": "tomas.ehrlich@gmail.com"
},
"license... | 5,156 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/react/tsconfig.json | {
"extends": "../../tsconfig.json",
"compilerOptions": {
"strict": true,
"noUncheckedIndexedAccess": true,
"isolatedModules": true,
"forceConsistentCasingInFileNames": true,
}
}
| 5,157 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/I18nProvider.test.tsx | import * as React from "react"
import { act, render } from "@testing-library/react"
import { I18nProvider, useLingui } from "./I18nProvider"
import { I18n, setupI18n } from "@lingui/core"
import { useMemo } from "react"
describe("I18nProvider", () => {
it(
"should pass i18n context to wrapped components, " +
... | 5,158 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/I18nProvider.tsx | import React, { ComponentType, FunctionComponent } from "react"
import type { I18n } from "@lingui/core"
import type { TransRenderProps } from "./TransNoContext"
export type I18nContext = {
i18n: I18n
_: I18n["_"]
defaultComponent?: ComponentType<TransRenderProps>
}
export type I18nProviderProps = Omit<I18nCont... | 5,159 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/Trans.test.tsx | import * as React from "react"
import { render } from "@testing-library/react"
import {
Trans,
I18nProvider,
TransRenderProps,
TransRenderCallbackOrComponent,
} from "@lingui/react"
import { setupI18n } from "@lingui/core"
import { mockConsole } from "@lingui/jest-mocks"
import { PropsWithChildren } from "react... | 5,160 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/Trans.tsx | import React from "react"
import { useLingui } from "./I18nProvider"
import { TransNoContext, TransProps } from "./TransNoContext"
export function Trans(props: TransProps): React.ReactElement<any, any> | null {
const lingui = useLingui()
return React.createElement(TransNoContext, { ...props, lingui })
}
| 5,161 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/TransNoContext.tsx | import React, { ComponentType } from "react"
import { formatElements } from "./format"
import type { MessageOptions } from "@lingui/core"
import { I18n } from "@lingui/core"
export type TransRenderProps = {
id: string
translation: React.ReactNode
children: React.ReactNode
message?: string | null
/**
* @d... | 5,162 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/format.test.tsx | import * as React from "react"
import { render } from "@testing-library/react"
import { formatElements } from "./format"
// eslint-disable-next-line import/no-extraneous-dependencies
import { mockConsole } from "@lingui/jest-mocks"
describe("formatElements", function () {
const html = (elements: React.ReactNode) =>
... | 5,163 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/format.ts | import React from "react"
// match <tag>paired</tag> and <tag/> unpaired tags
const tagRe = /<([a-zA-Z0-9]+)>(.*?)<\/\1>|<([a-zA-Z0-9]+)\/>/
const nlRe = /(?:\r\n|\r|\n)/g
// For HTML, certain tags should omit their close tag. We keep a whitelist for
// those special-case tags.
const voidElementTags = {
area: true,... | 5,164 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/index.ts | export { I18nProvider, useLingui, LinguiContext } from "./I18nProvider"
export type { I18nProviderProps, I18nContext } from "./I18nProvider"
export { Trans } from "./Trans"
export type {
TransProps,
TransRenderProps,
TransRenderCallbackOrComponent,
} from "./TransNoContext"
| 5,165 |
0 | petrpan-code/lingui/js-lingui/packages/react | petrpan-code/lingui/js-lingui/packages/react/src/server.ts | /**
* This is an entry point for React Server Components (RSC)
*
* The RSC uses a static analysis to find any non-valid function calls in the import graph.
* That means this entry point and it's children should not have any Provider/Context calls.
*/
export { TransNoContext } from "./TransNoContext"
export type {... | 5,166 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/remote-loader/CHANGELOG.md | # Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [3.11.0](https://github.com/lingui/js-lingui/compare/v3.10.4...v3.11.0) (2021-09-07)
### Bug Fixes
* sideEffects to false for shrinking bundle size ... | 5,167 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/remote-loader/README.md | [![License][badge-license]][license]
[![Version][badge-version]][package]
[![Downloads][badge-downloads]][package]
# @lingui/remote-loader
Load your `.json` catalogs remotely.
> This tool is useful when you have plain .json files which are messages/catalogs, but Lingui needs them compiled, this tool under the hood w... | 5,168 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/remote-loader/package.json | {
"name": "@lingui/remote-loader",
"version": "3.11.0",
"sideEffects": false,
"private": true,
"description": "Load remotely your translations",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"author": {
"name": "Sergio Moreno",
"email": "sergiomorenoal... | 5,169 |
0 | petrpan-code/lingui/js-lingui/packages/remote-loader | petrpan-code/lingui/js-lingui/packages/remote-loader/src/browserCompiler.ts | import { compileMessage } from "@lingui/message-utils/compileMessage"
export function createBrowserCompiledCatalog(messages: Record<string, any>) {
return Object.keys(messages).reduce((obj, key: string) => {
const value = messages[key]
const translation = value || key
obj[key] = compileMessage(translat... | 5,170 |
0 | petrpan-code/lingui/js-lingui/packages/remote-loader | petrpan-code/lingui/js-lingui/packages/remote-loader/src/index.ts | import * as R from "ramda"
import { createBrowserCompiledCatalog } from "./browserCompiler"
import PARSERS from "./minimalParser"
type RemoteLoaderOpts<T> = {
format?: "minimal"
fallbackMessages?: string | Record<string, any> | T
messages: string | Record<string, any> | T
}
function remoteLoader<T>({
format =... | 5,171 |
0 | petrpan-code/lingui/js-lingui/packages/remote-loader | petrpan-code/lingui/js-lingui/packages/remote-loader/src/minimalParser.ts | import * as R from "ramda"
const deserialize = R.map((translation: string) => ({
translation,
obsolete: false,
message: null,
origin: [],
})) as unknown as (minimalCatalog: any) => any
const PARSERS = {
minimal: <T>(content: Record<string, any> | T) => {
return deserialize(content)
},
}
export defaul... | 5,172 |
0 | petrpan-code/lingui/js-lingui/packages/remote-loader | petrpan-code/lingui/js-lingui/packages/remote-loader/test/index.test.ts | import { remoteLoader } from "../src"
import fs from "fs"
describe("remote-loader", () => {
it("should compile correctly JSON messages coming from the fly", async () => {
const unlink = createConfig("minimal")
const messages = await simulatedJsonResponse()
const remoteMessages = remoteLoader({ format: "m... | 5,173 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/vite-plugin/CHANGELOG.md | # Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [4.5.0](https://github.com/lingui/js-lingui/compare/v4.4.2...v4.5.0) (2023-09-14)
**Note:** Version bump only for package @lingui/vite-plugin
## [4.4... | 5,174 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/vite-plugin/README.md | [![License][badge-license]][license]
[![Version][badge-version]][package]
[![Downloads][badge-downloads]][package]
# @lingui/vite-plugin
> Vite plugin that compiles Lingui catalogs on the fly. In summary, the `lingui compile` command isn't needed when using this plugin.
`@lingui/vite-plugin` is part of [LinguiJS][li... | 5,175 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/vite-plugin/package.json | {
"name": "@lingui/vite-plugin",
"version": "4.5.0",
"description": "Vite plugin for Lingui message catalogs",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"sideEffects": false,
"license": "MIT",
"keywords": [
"vite-plugin",
"i18n",
"vite",
"l... | 5,176 |
0 | petrpan-code/lingui/js-lingui/packages | petrpan-code/lingui/js-lingui/packages/vite-plugin/tsconfig.json | {
"compilerOptions": {
"module": "commonjs",
"target": "ES2019",
"sourceMap": true,
"noEmit": false,
"declaration": true,
"outDir": "./build",
"esModuleInterop": true,
"resolveJsonModule": true,
"types": []
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
}
| 5,177 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin | petrpan-code/lingui/js-lingui/packages/vite-plugin/src/index.ts | import { getConfig } from "@lingui/conf"
import {
createCompiledCatalog,
getCatalogs,
getCatalogForFile,
getCatalogDependentFiles,
} from "@lingui/cli/api"
import path from "path"
import type { Plugin } from "vite"
const fileRegex = /(\.po|\?lingui)$/
type LinguiConfigOpts = {
cwd?: string
configPath?: st... | 5,178 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/default-vite.config.ts | import { UserConfig } from "vite"
import { lingui } from "../src/index"
import path from "path"
export function createDefaultViteConfig(dirname: string): UserConfig {
return {
build: {
lib: {
entry: path.resolve(dirname, "entrypoint.js"),
fileName: "bundle",
formats: ["cjs"],
... | 5,179 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/index.ts | import path from "path"
import { exec as _exec } from "child_process"
import { mkdtempSync } from "fs"
import os from "os"
const skipOnWindows = os.platform() === "win32" ? it.skip : it
describe("vite-plugin", () => {
skipOnWindows("should return compiled catalog", async () => {
const mod = await runVite(`po-fo... | 5,180 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/__snapshots__/index.ts.snap | // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`vite-plugin should not report error when macro correctly used 1`] = `Ola`;
exports[`vite-plugin should return compiled catalog 1`] = `
{
mVmaLu: [
My name is ,
[
name,
],
],
mY42CM: Hello World,
}
`;
exports[`vite-plugin should return compil... | 5,181 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/json-format/entrypoint.js | export async function load() {
return await import("./locale/en.json?lingui")
}
| 5,182 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/json-format/lingui.config.ts | import { formatter } from "@lingui/format-json"
export default {
locales: ["en"],
catalogs: [
{
path: "<rootDir>/locale/{locale}",
},
],
fallbackLocales: {
default: "en",
},
format: formatter({ style: "minimal" }),
}
| 5,183 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/json-format/vite.config.ts | import { createDefaultViteConfig } from "../default-vite.config"
export default createDefaultViteConfig(__dirname)
| 5,184 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/json-format | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/json-format/locale/en.json | {
"key": "Message",
"key2": "Hello {name}"
}
| 5,185 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/macro-usage/.linguirc | {
"locales": ["en"],
"catalogs": [{
"path": "<rootDir>/locale/{locale}"
}],
"fallbackLocales": {
"default": "en"
},
"format": "po"
}
| 5,186 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/macro-usage/entrypoint.js | import { t } from "@lingui/macro"
export async function load() {
return t`Ola`
}
| 5,187 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/macro-usage/vite.config.ts | import { createDefaultViteConfig } from "../default-vite.config"
import { UserConfig } from "vite"
import macrosPlugin from "vite-plugin-babel-macros"
const config: UserConfig = {
...createDefaultViteConfig(__dirname),
}
config.plugins.push(macrosPlugin())
export default config
| 5,188 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/macro-usage | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/macro-usage/locale/en.po | msgid "Hello World"
msgstr "Hello World"
msgid "My name is {name}"
msgstr "My name is {name}"
| 5,189 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/no-macro-error/.linguirc | {
"locales": ["en"],
"catalogs": [{
"path": "<rootDir>/locale/{locale}"
}],
"fallbackLocales": {
"default": "en"
},
"format": "po"
}
| 5,190 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/no-macro-error/entrypoint.js | import { t } from "@lingui/macro"
export async function load() {
return t`Ola`
}
| 5,191 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/no-macro-error/vite.config.ts | import { createDefaultViteConfig } from "../default-vite.config"
export default createDefaultViteConfig(__dirname)
| 5,192 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/no-macro-error | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/no-macro-error/locale/en.po | msgid "Hello World"
msgstr "Hello World"
msgid "My name is {name}"
msgstr "My name is {name}"
| 5,193 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/po-format/.linguirc | {
"locales": ["en"],
"catalogs": [{
"path": "<rootDir>/locale/{locale}"
}],
"fallbackLocales": {
"default": "en"
},
"format": "po"
}
| 5,194 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/po-format/entrypoint.js | export async function load() {
return import("./locale/en.po")
}
| 5,195 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/po-format/vite.config.ts | import { createDefaultViteConfig } from "../default-vite.config"
export default createDefaultViteConfig(__dirname)
| 5,196 |
0 | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/po-format | petrpan-code/lingui/js-lingui/packages/vite-plugin/test/po-format/locale/en.po | msgid "Hello World"
msgstr "Hello World"
msgid "My name is {name}"
msgstr "My name is {name}"
| 5,197 |
0 | petrpan-code/lingui/js-lingui | petrpan-code/lingui/js-lingui/scripts/verdaccio-release.ts | import { exec as _exec, ExecOptions } from "child_process"
import ora from "ora"
import chalk from "chalk"
async function releaseInVerdaccio() {
const spinner = ora()
// Throw away build stats
spinner.start("Logging in Verdaccio")
await exec(
`npx npm-cli-login -u test -p test -e test@test.com -r http://0... | 5,198 |
0 | petrpan-code/lingui/js-lingui/scripts | petrpan-code/lingui/js-lingui/scripts/jest/env.js | // avoid snapshot of cli output mismatching because
// of different ways to run test
process.env.npm_config_user_agent = "yarn"
| 5,199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.