{"id":17965346,"url":"https://github.com/t2ym/gulp-i18n-at-once","last_synced_at":"2025-04-03T20:17:44.915Z","repository":{"id":57257820,"uuid":"62387419","full_name":"t2ym/gulp-i18n-at-once","owner":"t2ym","description":"Perform integrated I18N processes for Polymer i18n-behavior at once","archived":false,"fork":false,"pushed_at":"2016-08-16T10:34:07.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T12:04:20.599Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t2ym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-01T11:08:59.000Z","updated_at":"2016-07-01T11:10:19.000Z","dependencies_parsed_at":"2022-08-25T21:23:34.268Z","dependency_job_id":null,"html_url":"https://github.com/t2ym/gulp-i18n-at-once","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Fgulp-i18n-at-once","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Fgulp-i18n-at-once/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Fgulp-i18n-at-once/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t2ym%2Fgulp-i18n-at-once/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t2ym","download_url":"https://codeload.github.com/t2ym/gulp-i18n-at-once/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247070927,"owners_count":20878586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T12:41:47.213Z","updated_at":"2025-04-03T20:17:44.885Z","avatar_url":"https://github.com/t2ym.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-i18n-at-once\n\nPerform integrated I18N processes for Polymer [i18n-behavior](https://github.com/t2ym/i18n-behavior) at once (experimental)\n\n### Note: Currently only applicable to [Polymer CLI](https://github.com/Polymer/polymer-cli)/[polymer-build](https://github.com/Polymer/polymer-build) style projects with the project root as its source root.\n\n## Install\n\n```\n    npm install --save-dev gulp-i18n-at-once\n```\n\n## Integrated I18N Processes\n\n  - scan - Scan HTMLs and construct localizable attributes repository\n  - basenameSort - Sort source files according to their base names; Bundle files come first.\n  - dropDefaultJSON - Drop default JSON files to avoid overwriting new ones \n  - preprocess - Preprocess Polymer templates for I18N\n  - tmpJSON - Store extracted JSON in the temporary folder .tmp\n  - importXliff - Import XLIFF into JSON\n  - leverage - Merge changes in default JSON into localized JSON\n  - exportXliff - Generate bundles and export XLIFF\n  - feedback - Update JSON and XLIFF in sources\n\n## Usage\n\nApplied to the `gulpfile.js` from [`generator-polymer-init-custom-build`](https://github.com/PolymerElements/generator-polymer-init-custom-build) for Polymer CLI\n\n```javascript\n/**\n* @license\n* Copyright (c) 2016 The Polymer Project Authors. All rights reserved.\n* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt\n* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt\n* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt\n* Code distributed by Google as part of the polymer project is also\n* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt\n*\n* Based on: https://github.com/Polymer/polymer-build/blob/master/test/test-project/gulpfile.js\n*/\n\n'use strict';\n\nconst del = require('del');\nconst gulp = require('gulp');\nconst gulpif = require('gulp-if');\nconst imagemin = require('gulp-imagemin');\nconst logging = require('plylog');\nconst mergeStream = require('merge-stream');\n\n// Got problems? Try logging 'em\n// logging.setVerbose();\n\nconst polymer = require('polymer-build');\nconst PolymerProject = polymer.PolymerProject;\nconst fork = polymer.forkStream;\nconst addServiceWorker = polymer.addServiceWorker;\n\nconst polymerJSON = require('./polymer.json');\nconst project = new PolymerProject(polymerJSON);\n\n// ========================================== BEGIN\nconst debug = require('gulp-debug');\nconst i18nAtOnce = require('gulp-i18n-at-once');\n\nlet options = {\n  xliffOptions: {\n    xliffStates: {\n      'add'    : [ 'new' ],\n      'replace': [ 'needs-translation', 'needs-adaptation', 'needs-l10n', '' ],\n      'review' : [ 'needs-review-translation', 'needs-review-adaptation', 'needs-review-l10n' ],\n      'default': [ 'translated', 'signed-off', 'final', '[source~=nonTargets]', '[approved]' ]\n    },\n    patterns: {\n      'nonTargets': /^({{[^{} ]*}}|\\[\\[[^\\[\\] ]*\\]\\]|\u003c[-a-zA-Z]{1,}\u003e|[0-9.]{1,}|[a-zA-Z]{1,}_[a-zA-Z_]{1,}|\\/images\\/.*|data:image\\/jpeg;.*)$/,\n      'annotationsAndTags': /^({{[^{} ]*}}|\\[\\[[^\\[\\] ]*\\]\\]|\u003c[-a-zA-Z]{1,}\u003e)$/,\n      'annotations': /^({{[^{} ]*}}|\\[\\[[^\\[\\] ]*\\]\\])$/,\n      'numbers': /^[0-9.]{1,}$/,\n      'tags': /^\u003c[-a-zA-Z]{1,}\u003e$/\n    }\n  }\n};\n// ========================================== END\n\n// Clean build directory\ngulp.task('clean', () =\u003e {\n  return del('build');\n});\n\ngulp.task('build', ['clean'], (cb) =\u003e {\n  // ============================================= BEGIN\n  // i18n resources\n  const i18nResources = gulp.src([ 'bundle.json', 'locales/**', 'xliff/**' ], { base: '.' });\n  // ============================================= END\n\n  // process source files in the project\n  const sources = mergeStream(project.sources(), i18nResources)\n    .pipe(project.splitHtml())\n    // add compilers or optimizers here!\n    // for example, to process JS files\n    // .pipe(gulpif('**/*.js', babel( // babel settings )))\n    // included is an example demonstrating how to\n    // compress images\n    //.pipe(gulpif('**/*.{png,gif,jpg,svg}', imagemin({\n    //  progressive: true, interlaced: true\n    //})))\n    // ============================================= BEGIN\n    // I18N processes\n    .pipe(i18nAtOnce(options))\n    .pipe(debug({ title: 'I18N Transform' }))\n    // ============================================= END\n    .pipe(project.rejoinHtml());\n\n  // ============================================= BEGIN\n  // images and json resources (for the Shop App)\n  const resources = gulp.src([ 'images/**', 'data/**' ], { base: '.' });\n  // ============================================= END\n\n  // process dependencies (basically the stuff coming out of bower_components)\n  // you can probably ignore these steps but if you want to do something\n  // specific for your installed dependencies, this is the place to do it\n  const dependencies = project.dependencies()\n    .pipe(project.splitHtml())\n     // add code to process your installed dependencies here  \n    .pipe(project.rejoinHtml());\n\n  // ============================================= BEGIN\n  // dynamically loaded step dependencies skipped in project.dependencies()\n  const stepDependencies = gulp.src([ 'bower_components/intl/**', 'bower_components/region-flags/**' ], { base: '.' });\n  // ============================================= END\n\n  // ============================================= BEGIN\n  // merge the source and dependencies streams to we can analyze the project\n  const mergedFiles = mergeStream(sources, resources, dependencies, stepDependencies)\n    .pipe(project.analyzer);\n  // ============================================= END\n\n  // this fork will vulcanize the project\n  const bundledPhase = fork(mergedFiles)\n    .pipe(project.bundler)\n    // write to the bundled folder\n    .pipe(gulp.dest('build/bundled'));\n\n  const unbundledPhase = fork(mergedFiles)\n    // write to the unbundled folder\n    .pipe(gulp.dest('build/unbundled'));\n\n  cb();\n});\n\ngulp.task('service-worker', ['build'], () =\u003e {\n  const swConfig = {\n    navigateFallback: '/index.html',\n  };\n\n  // Once the unbundled build stream is complete, create a service worker for the build\n  const unbundledPostProcessing = addServiceWorker({\n    project: project,\n    buildRoot: 'build/unbundled',\n    swConfig: swConfig,\n    serviceWorkerPath: 'service-worker.js',\n  });\n\n  // Once the bundled build stream is complete, create a service worker for the build\n  const bundledPostProcessing = addServiceWorker({\n    project: project,\n    buildRoot: 'build/bundled',\n    swConfig: swConfig,\n    bundled: true,\n  });\n});\n\ngulp.task('default', ['service-worker']);\n```\n\n## API\n\n`i18nAtOnce(options)`\n\n### `options` object\n\nTBD\n\n## License\n\n[BSD-2-Clause](https://github.com/t2ym/gulp-i18n-preprocess/blob/master/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft2ym%2Fgulp-i18n-at-once","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft2ym%2Fgulp-i18n-at-once","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft2ym%2Fgulp-i18n-at-once/lists"}