{"_id":"@emilioforrer/adonis-translatable","_rev":"4-50aabb18db9594a537210db993f7f4a2","name":"@emilioforrer/adonis-translatable","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@emilioforrer/adonis-translatable","version":"1.0.0","description":"AdonisJS Lucid internationalization models","main":"index.js","scripts":{"lint":"standard","pretest":"npm run lint","test":"node ./node_modules/nyc/bin/nyc.js ./node_modules/japa-cli/index.js"},"keywords":["adonisjs","adonis-framework","database","internationalization","localization","translation","lucid"],"author":{"name":"Emilio Forrer"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/emilioforrer/adonis-translatable.git"},"bugs":{"url":"https://github.com/emilioforrer/adonis-translatable/issues"},"homepage":"https://github.com/emilioforrer/adonis-translatable#readme","nyc":{"exclude":["src/Exceptions","providers","test","bin"]},"standard":{"globals":["use"]},"devDependencies":{"@adonisjs/ace":"^5.0.1","@adonisjs/fold":"^4.0.8","@adonisjs/framework":"^5.0.6","@adonisjs/lucid":"^5.0.3","@adonisjs/sink":"^1.0.13","@adonisjs/validator":"^5.0.3","japa":"^1.0.5","japa-cli":"^1.0.1","nyc":"^11.7.1","sqlite3":"^4.0.0","standard":"^10.0.3"},"dependencies":{"@adonisjs/antl":"^2.0.5","pluralize":"^7.0.0"},"licenseText":"MIT License\n\nCopyright (c) 2018 Emilio Forrer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@emilioforrer/adonis-translatable@1.0.0","dist":{"shasum":"5def0834d06091e1616c050647c5058e97095feb","tarball":"https://registry.npmjs.org/@emilioforrer/adonis-translatable/-/adonis-translatable-1.0.0.tgz","fileCount":21,"unpackedSize":127973,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa70eKCRA9TVsSAnZWagAABMUP/Rzxv5L4f97HohYyVJNl\n9UcboqQ+VQl/rCUP6iRgHBYJBRLNrvzqOgX0pHWKaaV7knhC1234ENtKd386\nx+fUkOp6rovrlP+xQrqB1Cp9D4CV2WyT2x1S37RWFJ227k2ndZAdcTRhlSWx\nQGisApLYWytTTFN2x2ZTtLpHhyhHbubmhJt/g4zmEIh02u/uLzrPI8AdSPHl\nPerGoNjCmjV8mtcq9RC/HLnCxlj09k9HJuHYZuylLWGO9zSPAxuu7yTwCJkS\nhfB4L5IOj5d4KidiG1wj9A7P0WBriFLF59L1zRJ1w6YE4h18U02aKy0mMR4x\nzi3k9ui9VEZMWH02A1EjyeYIxRIeGcXBjxJm2RbRrx96sz7cN2509bj/yPHP\nNVwrdl2u+8zlqVT6RxOCjoVzLiObXyvBmGGHunczMvLn/7Itmu2mfRVqgrow\n6NZxHLnUKjQeqUQXkemrUhCnTzC23O3w/sP1KAbV5QVrxCwLojLxiS8xiIqp\nXDOkiCKRIJDKZM+Zqs+jisxM/kX4oxJc925ksltZhiEOuzbeYjWi5vkdfq64\n6iLbIMg4ueDwMd8Tt6DnR1cjH577bFbPevXN/xFwRH0jZGwEWQj9aO0CgCVn\ngSwgIKUCT9r2UhUbLfPh6lcBieqP1p3M275dj1nPkoB8mUw3uPrHCCAQcNqt\ncLCS\r\n=82Hg\r\n-----END PGP SIGNATURE-----\r\n","integrity":"sha512-/vP3l21jft/X5Hyn3D6JOaW2jJ4JEwdM6tvS9kd7F662twkfmK/2fZleYH6cz2kPFwhDYcG8iWSWTwrDbveIYg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGvbNlPFQxIuzbV6eBC/W88vytikOcrUpScXD5wW0f9uAiBV3ZmErieuBH20vs6qUljDTyqy8W5KYuYJFGM14A1X2w=="}]},"maintainers":[{"name":"emilioforrer","email":"dev.emilio.forrer@gmail.com"}],"_npmUser":{"name":"emilioforrer","email":"dev.emilio.forrer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/adonis-translatable_1.0.0_1525630855736_0.7395607888667179"},"_hasShrinkwrap":false},"1.0.1":{"name":"@emilioforrer/adonis-translatable","version":"1.0.1","description":"AdonisJS Lucid internationalization models","main":"index.js","scripts":{"lint":"standard","pretest":"npm run lint","test":"node ./node_modules/nyc/bin/nyc.js ./node_modules/japa-cli/index.js"},"keywords":["adonisjs","adonis-framework","database","internationalization","localization","translation","lucid"],"author":{"name":"Emilio Forrer"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/emilioforrer/adonis-translatable.git"},"bugs":{"url":"https://github.com/emilioforrer/adonis-translatable/issues"},"homepage":"https://github.com/emilioforrer/adonis-translatable#readme","nyc":{"exclude":["src/Exceptions","providers","test","bin"]},"standard":{"globals":["use"]},"devDependencies":{"@adonisjs/ace":"^5.0.1","@adonisjs/fold":"^4.0.8","@adonisjs/framework":"^5.0.6","@adonisjs/lucid":"^5.0.3","@adonisjs/sink":"^1.0.13","@adonisjs/validator":"^5.0.3","japa":"^1.0.5","japa-cli":"^1.0.1","nyc":"^11.7.1","sqlite3":"^4.0.0","standard":"^10.0.3"},"dependencies":{"@adonisjs/antl":"^2.0.5","pluralize":"^7.0.0"},"licenseText":"MIT License\n\nCopyright (c) 2018 Emilio Forrer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@emilioforrer/adonis-translatable@1.0.1","dist":{"shasum":"39cce84f6049e8e46f6f77c534638af94b306623","tarball":"https://registry.npmjs.org/@emilioforrer/adonis-translatable/-/adonis-translatable-1.0.1.tgz","integrity":"sha512-CIqK+nLFcsBFQMnWImd1qqK6/Ucx/xCQ0m0u+6CHf+b92kkL7yG9upyXyvOndBB13brO85NmRnjWKJmQdOPJbw==","fileCount":22,"unpackedSize":128761,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb75iCCRA9TVsSAnZWagAA+68P/0frF+dsO3h5NkCCw5HU\niIjOeibLEp+MI3RJ1XqZxWtNlWaNT8ggA0Qs+BWduTxC/7TN5tNCnU9fEpQT\nBmFrIqKAF+k+EDSMNK/diakQVx1b08gNgZF0yG3RKP9JTU4aCwddvxKVfoAt\nqo3EwheWIkaf9IATNTjdVFSXpo2CB0t8xG3cjJyK9K1TUxNbDgzK5R0Fn0ch\nbMazsqbXSo9tlJkN0z0mRGWDSU0WCotZf8ogGVPzUXSzBaYJqSuHsProGEVf\njs6tuw5B3cpkeldjJQSdHv3um/DJJZI9aXkje9VJUerZ3mq8aELwewbYVg8u\n1oseIn1/C6IfOM5YKC3ZtrEtaFv+6LA8fvWvPhGS8jT8X9Qm8bu00alsxthZ\n/DPwa3WS7ybelLQjuGN1OzBCxooZPFUQk6rjDUAtGzM8yhAMVj9n7I5N35hU\npQfJHf1htYKYLhiXllLOFjVmTQ5bLtHRE9yTSs3BTJ0W+7p8RqiFJ2D6GJWA\na5JYLhBEwcqTDWX+MVDDGEpEmhnzBuMKD7hwYcAVdrFtLfEk+CMdeZMgjj2j\nmL4+KUg4Niyf2JSa/D4zjnOUfzIGnfo7P8q2SnYrAIce3/Yq9BJYpJMQXY4u\n6j0dTkzIwwbOtl7aDXOSPaTp1gs8rh3Ki9d6miU3PKzrplh9izuohm1N8SJt\nljGZ\r\n=SCbQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCAvqKe1JVjjAYXZT2ZHYDig/fBRKHmVISCYgYMVC7mRAIhAKysPzPhiTMgpED0Tecl2+OTzNz3acvvUuZmV28k/gKs"}]},"maintainers":[{"name":"emilioforrer","email":"dev.emilio.forrer@gmail.com"}],"_npmUser":{"name":"emilioforrer","email":"dev.emilio.forrer@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/adonis-translatable_1.0.1_1542428801871_0.32361196094319267"},"_hasShrinkwrap":false}},"time":{"created":"2018-05-06T18:20:55.682Z","1.0.0":"2018-05-06T18:20:55.819Z","modified":"2022-06-12T17:33:15.452Z","1.0.1":"2018-11-17T04:26:41.998Z"},"maintainers":[{"name":"emilioforrer","email":"dev.emilio.forrer@gmail.com"}],"description":"AdonisJS Lucid internationalization models","homepage":"https://github.com/emilioforrer/adonis-translatable#readme","keywords":["adonisjs","adonis-framework","database","internationalization","localization","translation","lucid"],"repository":{"type":"git","url":"git+https://github.com/emilioforrer/adonis-translatable.git"},"author":{"name":"Emilio Forrer"},"bugs":{"url":"https://github.com/emilioforrer/adonis-translatable/issues"},"license":"MIT","readme":"# Adonis Translatable\n\nAdonisJS Lucid internationalization models.\n\n## Installation\n\n**npm**\n\n```\nnpm install @emilioforrer/adonis-translatable\n```\n\n**yarn**\n\n```\nyarn add @emilioforrer/adonis-translatable\n```\n\n\nAdd the provider to your start/app.js file:\n\n```js\nconst providers = [\n   // ...\n   \"@emilioforrer/providers/TranslatableProvider\",\n   // ...\n ];\n```\n\n## How it works\n\nBasically this addon creates a new relationship called `translations` to main model and delegates it's translatable attributes to the translation model.\n\nSo in order to work, you need to create a new model translations for your main model, add a trait and configure it.\n\n## How to use\n\nLet's say we have a model `App/Models/Role` and want to translate the name and description attributes, in order to do that follow the next steps.\n\n1. Let's create the translation table for the model `App/Models/Role`.\n\n```js\nschema.createTable('roles_translations', (table) => {\n  table.increments()\n  table.timestamps()\n  /*\n   * Translation fields\n   */\n  table.string('name').nullable()\n  table.text('description').nullable()\n  table.integer('role_id').unsigned()\n  table.string('language_code')\n})\n```\n2. Now let's create the translation model `App/Models/RoleTranslation`\n\n```js\nconst Model = app.use('Model')\nclass RoleTranslation extends Model {\n  static get table () {\n    return 'roles_translations'\n  }\n}\n```\n\n3. Next, we need to add a `trait` to the main model (`App/Models/Role`) and configure the options\n\n```js\nconst Model = app.use('Model')\nclass Role extends Model {\n  static boot () {\n    super.boot()\n    this.addTrait('Translatable', {\n      className: 'App/Models/RoleTranslation',\n      attributes: ['name', 'description']\n    })\n  }\n}\n```\n\n## Translatable trait options\n\n* **className:** The name of the translation model. Defaults to: `''`.\n* **primaryKey:** This is the primary key that will be used to create the `translation` relationship. Defaults to: `Model.primaryKey`.\n* **foreignKey:** This is the foreign key that will be used to create the `translation` relationship. Defaults to: `${singlularized_table_name}_id`.\n* **attributes:** The list of attributes that we wish to be delegated to the translation model.\n\n## Development\n\nGreat! If you are planning to contribute to the framework, make sure to adhere to following conventions, since a consistent code-base is always joy to work with.\n\nRun the following command to see list of available npm scripts.\n\n**npm**\n\n```bash\nnpm run\n```\n\n**yarn**\n\n```bash\nyarn run\n```\n\n### Tests & Linting\n\n1. Lint your code using standardJs. Run `yarn run lint` command to check if there are any linting errors.\n2. Make sure you write tests for all the changes/bug fixes.\n3. Run `yarn run test` to lint and run your tests.\n","readmeFilename":"README.md"}