Improve i18n-js generation and use

This commit is contained in:
Eric Schultz 2020-11-24 16:20:51 -06:00 committed by Eric Schultz
parent de840411fb
commit fcdd5bcbab
21 changed files with 355 additions and 170 deletions

View file

@ -438,5 +438,7 @@ app/javascript/legacy_react/src/components/session_login_page/SessionLoginPage.t
#included code from another package
app/javascript/common/lodash-joins
#javascript locales
app/javascript/i18n/locales
# don't check any js in the installed gems on build server
vendor/bundle
vendor/bundle

View file

@ -18,6 +18,12 @@ jobs:
node: [14.6.0]
steps:
- uses: actions/checkout@v2
- name: Setup PostgreSQL with PostgreSQL extensions and unprivileged user
uses: Daniel-Marynicz/postgresql-action@0.1.0
with:
postgres_image_tag: 11-alpine
postgres_user: houdini_user
postgres_password: password
- uses: actions/setup-node@v1.4.4
with:
node-version: ${{ matrix.node }}
@ -47,6 +53,7 @@ jobs:
bundle config deployment true
bundle config path vendor/bundle
bundle install --jobs 4
- run: bin/setup ci
- name: run eslint
run: yarn eslint
jest:
@ -57,6 +64,12 @@ jobs:
node: [14.6.0]
steps:
- uses: actions/checkout@v2
- name: Setup PostgreSQL with PostgreSQL extensions and unprivileged user
uses: Daniel-Marynicz/postgresql-action@0.1.0
with:
postgres_image_tag: 11-alpine
postgres_user: houdini_user
postgres_password: password
- uses: actions/setup-node@v1.4.4
with:
node-version: ${{ matrix.node }}
@ -86,6 +99,7 @@ jobs:
bundle config deployment true
bundle config path vendor/bundle
bundle install --jobs 4
- run: bin/setup ci
- name: run jest
run: yarn jest
webpack:
@ -94,7 +108,6 @@ jobs:
matrix:
os: [ubuntu-latest]
node: [14.6.0]
ruby: [2.6.6]
steps:
- uses: actions/checkout@v2
- name: Setup PostgreSQL with PostgreSQL extensions and unprivileged user
@ -135,7 +148,7 @@ jobs:
- name: run setup
run: bin/setup ci
- name: Webpack compile everything
run: bin/webpack
run: yarn webpack
- name: Verify storybook compiles
run: yarn build-storybook

3
.gitignore vendored
View file

@ -74,5 +74,8 @@ yarn-debug.log*
# we don't want the file storage directory to be committed
storage
# the locales directory in javascript is generated at run time.
app/javascript/i18n/locales
# No package-lock.json file from npm
package-lock.json

View file

@ -25,7 +25,7 @@ gem 'sprockets', '~> 3.7'
gem 'chronic', '~> 0.10.2' # For nat lang parsing of dates
gem 'countries', '~> 3.0'
gem 'geocoder', '~> 1.6.3' # for adding latitude and longitude to location-based tables http://www.rubygeocoder.com/
gem 'i18n-js', '~> 3.3'
gem 'i18n-js', '~> 3.8', git: 'https://github.com/houdiniproject/i18n-js.git', branch: 'houdini-tweaks'
gem 'lograge', '~> 0.11.2' # make logging less terrible in rails
gem 'nearest_time_zone', '~> 0.0.4' # for detecting timezone from lat/lng https://github.com/buytruckload/nearest_time_zone
gem 'rails-i18n', '~> 6.0.0', '~> 6'

View file

@ -8,6 +8,14 @@ GIT
multi_json (~> 1.0)
stripe (>= 1.31.0, <= 1.58.0)
GIT
remote: https://github.com/houdiniproject/i18n-js.git
revision: a506f9f66de91f9e73715231c6509d252fbb2509
branch: houdini-tweaks
specs:
i18n-js (3.8.0)
i18n (>= 0.6.6)
PATH
remote: gems/bess
specs:
@ -171,8 +179,6 @@ GEM
multi_xml (>= 0.5.2)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
i18n-js (3.3.0)
i18n (>= 0.6.6)
i18n_data (0.8.0)
image_processing (1.10.3)
mini_magick (>= 4.9.5, < 5)
@ -427,7 +433,7 @@ DEPENDENCIES
heroku-deflater (~> 0.6.3)
houdini_full_contact!
httparty (~> 0.17.0)
i18n-js (~> 3.3)
i18n-js (~> 3.8)!
image_processing (~> 1.10.3)
jbuilder (~> 2.10)
listen

260
NOTICE-js
View file

@ -1073,6 +1073,8 @@ Copyright (c) Microsoft Corporation.
Copyright (c) Microsoft Corporation.
** @types/html-minifier-terser; version 5.1.0 --
Copyright (c) Microsoft Corporation.
** @types/i18n-js; version 3.0.3 --
Copyright (c) Microsoft Corporation.
** @types/invariant; version 2.2.33 --
Copyright (c) Microsoft Corporation.
** @types/is-function; version 1.0.0 --
@ -1081,8 +1083,6 @@ Copyright (c) Microsoft Corporation.
Copyright (c) Microsoft Corporation.
** @types/istanbul-lib-report; version 3.0.0 --
Copyright (c) Microsoft Corporation.
** @types/istanbul-reports; version 1.1.2 --
Copyright (c) Microsoft Corporation.
MIT License
@ -3290,7 +3290,6 @@ For more information, please refer to <http://unlicense.org/>
** aws-sign2; version 0.7.0 -- https://github.com/mikeal/aws-sign#readme
Copyright 2010 LearnBoost <dev@learnboost.com>
** caseless; version 0.12.0 -- https://github.com/mikeal/caseless#readme
Apache License
@ -6748,6 +6747,8 @@ SOFTWARE.
------
** @types/istanbul-reports; version 1.1.2 --
Copyright (c) Microsoft Corporation.
** @types/jest; version 26.0.14 --
Copyright (c) Microsoft Corporation.
** @types/jquery; version 3.3.38 --
@ -7959,6 +7960,39 @@ SOFTWARE.
See the License for the specific language governing permissions and
limitations under the License.
** caseless; version 0.12.0 -- https://github.com/mikeal/caseless#readme
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
------
** doctrine; version 3.0.0 -- https://github.com/eslint/doctrine
Copyright JS Foundation and other contributors, https://js.foundation
Copyright (c) 2012, 2011 Ariya Hidayat (http://ariya.ofilabs.com/about) (twitter ariyahidayat (http://twitter.com/ariyahidayat)) and other contributors.
@ -10915,34 +10949,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------
** fast-deep-equal; version 3.1.3 -- https://github.com/epoberezkin/fast-deep-equal#readme
Copyright (c) 2017 Evgeny Poberezkin
MIT License
Copyright (c) 2017 Evgeny Poberezkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------
** chardet; version 0.7.0 -- https://github.com/runk/node-chardet
@ -14256,39 +14262,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------
** istanbul-lib-source-maps; version 4.0.0 -- https://istanbul.js.org/
Copyright 2015 Yahoo! Inc.
Copyright 2015, Yahoo Inc.
Copyright 2012-2015, Yahoo Inc.
Copyright 2015 Yahoo! Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Yahoo! Inc. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------
** hoist-non-react-statics; version 3.3.2 -- https://github.com/mridgway/hoist-non-react-statics#readme
@ -16344,6 +16317,34 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
------
** fast-deep-equal; version 3.1.3 -- https://github.com/epoberezkin/fast-deep-equal#readme
Copyright (c) 2017 Evgeny Poberezkin
MIT License
Copyright (c) 2017 Evgeny Poberezkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------
** functional-red-black-tree; version 1.0.1 -- https://github.com/mikolalysenko/functional-red-black-tree
@ -18704,6 +18705,39 @@ Redistribution and use in source and binary forms, with or without modification,
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------
** istanbul-lib-source-maps; version 4.0.0 -- https://istanbul.js.org/
Copyright 2015 Yahoo! Inc.
Copyright 2015, Yahoo Inc.
Copyright 2012-2015, Yahoo Inc.
Copyright 2015 Yahoo! Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Yahoo! Inc. nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
------
** moo; version 0.5.1 -- https://github.com/tjvr/moo#readme
@ -22606,9 +22640,6 @@ Copyright 2006, Jeremy White <jwhite@codeweavers.com>
Copyright 2009-2010, Fathi Boudra <fabo@freedesktop.org>
Copyright 2009-2010, Rex Dieter <rdieter@fedoraproject.org>
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
** os-locale; version 3.1.0 -- https://github.com/sindresorhus/os-locale#readme
(c) Sindre Sorhus (https://sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
MIT License
@ -26914,31 +26945,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------
** request-progress; version 2.0.1 -- https://github.com/IndigoUnited/node-request-progress
Copyright (c) 2012 IndigoUnited
Copyright (c) 2012 IndigoUnited
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
------
** react-aria-modal; version 3.1.0 -- https://github.com/davidtheclark/react-aria-modal#readme
@ -27853,6 +27859,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------
** os-locale; version 3.1.0 -- https://github.com/sindresorhus/os-locale#readme
(c) Sindre Sorhus (https://sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
** p-each-series; version 2.1.0 -- https://github.com/sindresorhus/p-each-series#readme
(c) Sindre Sorhus (https://sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
@ -30535,27 +30544,6 @@ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
------
** v8-to-istanbul; version 5.0.1 -- https://github.com/istanbuljs/v8-to-istanbul#readme
Copyright (c) 2017
Copyright (c) 2017, Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice
appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
------
** stealthy-require; version 1.1.1 -- https://github.com/analog-nico/stealthy-require#readme
@ -33289,6 +33277,31 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
------
** request-progress; version 2.0.1 -- https://github.com/IndigoUnited/node-request-progress
Copyright (c) 2012 IndigoUnited
Copyright (c) 2012 IndigoUnited
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
------
** tabbable; version 3.1.2 -- https://github.com/davidtheclark/tabbable#readme
@ -35543,6 +35556,27 @@ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
------
** v8-to-istanbul; version 5.0.1 -- https://github.com/istanbuljs/v8-to-istanbul#readme
Copyright (c) 2017
Copyright (c) 2017, Contributors
Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyright notice and this permission notice
appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
------
** wide-align; version 1.1.3 -- https://github.com/iarna/wide-align#readme

View file

@ -0,0 +1 @@
module.exports = {};

View file

@ -0,0 +1,2 @@
module.exports = 'test-file-stub';

View file

@ -5,7 +5,7 @@ import React from 'react';
import addons from '@storybook/addons';
import omit from 'lodash/omit';
import { IntlProvider} from '../../intl';
const messages = require('../../../i18n.js');
const messages = require('../../../i18n').default;
export let _config:any = null;

View file

@ -0,0 +1,55 @@
// License: LGPL-3.0-or-later
import React from 'react';
import { renderHook } from '@testing-library/react-hooks';
// yup errors are super confusing until formik turns them into something logical
import { validateYupSchema, yupToFormErrors } from 'formik';
import {IntlProvider, useIntl} from '../components/intl';
import I18n from '../i18n';
import useYup, {createMessage} from './useYup';
function Wrapper(props:React.PropsWithChildren<unknown>) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return <IntlProvider locale={'en'} messages={I18n.translations['en'] as any}>
{props.children}
</IntlProvider>;
}
describe("useYup", () => {
const nameLabel = 'Custom Name';
const customTranslationId = 'yup.mixed.default';
it('has the correct messages for locale', async() => {
expect.assertions(4);
const {result } = renderHook(() => useYup(), {wrapper: Wrapper});
const intl = renderHook(() => useIntl(), {wrapper: Wrapper});
const yup = result.current;
const schema = yup.object({
name: yup.string().label(nameLabel).min(20),
id: yup.string().required(createMessage(({ path}) => intl.result.current.formatMessage({id: customTranslationId}, {path}))),
address: yup.object({
city: yup.string().required(),
state: yup.string(),
}),
});
// This is the equivalent of getting errors from the FormikContext
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let errors:any = null;
try {
await validateYupSchema({name: "not 20 chars"}, schema, false);
}
catch(e) {
//turn into useful errors
errors = yupToFormErrors(e);
}
expect(errors.name).toMatch(/.*Custom Name.+20.*/);
expect(errors.id).toMatch(/.*id.*invalid.*/);
expect(errors.address.city).toMatch(/.*address.city.*required.*/);
expect(errors.address.state).toBeUndefined();
});
});

View file

@ -1,8 +0,0 @@
/* rails-erb-loader-dependencies ../config/locales/ */
const I18n = require('i18n-js');
I18n.translations = I18n.translations || {};
<% I18n::JS::translations.select{|k,v| Houdini.intl.available_locales.map{|i| i.to_s}.include?(k.to_s)}.each do |k,v| %>
I18n.translations['<%= k %>'] = I18n.extend((I18n.translations['<%= k %>'] || {}),<%= JSON.generate(v) %>);
<% end %>
module.exports = I18n;

View file

@ -0,0 +1,9 @@
// License: LGPL-3.0-or-later
require('./regenerate.js');
import I18n from 'i18n-js';
import locales from './locales';
I18n.translations = locales;
export default I18n;

View file

@ -0,0 +1,5 @@
/* rails-erb-loader-dependencies ../config/locales/ */
/* rails-erb-loader-dependencies ../config/i18n-js.yml */
/* License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later */
/* Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE */
<% GenerateLocales::generate %>

View file

@ -9,7 +9,7 @@ import {CSRFInterceptor} from "../../lib/csrf_interceptor";
import * as CustomAPIS from "../../lib/apis"
const I18n = require('../../../../i18n.js.erb')
const I18n = require('../../../../i18n').default
interface RootProps
{

View file

@ -1,3 +1,3 @@
const i18n = require('../i18n.js.erb')
const i18n = require('../i18n').default
window.I18n = i18n;

View file

@ -25,7 +25,17 @@
# - file: "app/assets/javascripts/i18n/translations.js"
# only: "*"
#
sort_translation_keys: true
fallbacks: true
translations:
- file: 'public/javascripts/translations.js'
only: '*'
prefix: "import I18n from 'i18n-js';\n"
prefix: "import I18n from 'i18n-js';\n"
- file: 'app/javascript/i18n/locales/%{locale}.ts'
js_extend: false
prefix: "// DO NOT MODIFY THIS FILE. MODIFY config/locales INSTEAD\nconst translations:any = {};"
suffix: "export default translations;"
only: '*'
houdini_ts: true

41
jest.config.js Normal file
View file

@ -0,0 +1,41 @@
module.exports = {
"testEnvironment": "jest-environment-jsdom-fifteen",
"testEnvironmentOptions": {
"enzymeAdapter": "react16",
},
"globals": {
"ts-jest": {
"babelConfig": false,
},
},
"modulePathIgnorePatterns": [
"<rootDir>/vendor", // don't go to the gems vendor folder. EVER.
],
"setupFiles": [
"<rootDir>/setupTests.js",
],
"transform": {
"^.+\\.tsx?$": "ts-jest",
},
"testPathIgnorePatterns": [
"/node_modules/",
"/config/webpack/test.js",
"/vendor/",
],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node",
],
"snapshotSerializers": [
"enzyme-to-json/serializer",
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/app/javascript/__mocks__/fileMock.js",
"\\./regenerate.js": "<rootDir>/app/javascript/__mocks__/erbMock.js",
},
};

20
lib/generate_locales.rb Normal file
View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
module GenerateLocales
def self.generate
I18n::JS::export
File.open(Rails.root.join('app', 'javascript', 'i18n', 'locales', 'index.ts'), 'w') do |file|
file << "// DO NOT MODIFY THIS FILE. AUTOGENERATED\n"
file << "const translations:Record<string,any> = {};\n\n"
I18n::JS::translations.select{|k,v| Houdini.intl.available_locales.map{|i| i.to_s}.include?(k.to_s)}.keys.each do |k|
file << "translations['#{k}'] = require('./#{k}').default['#{k}'];\n"
end
file << "\nexport default translations;"
end
end
end

19
lib/tasks/i18n_js.rake Normal file
View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
desc 'For generating the i18n-js exports at runtime. Overrides the built in i18n-js task'
namespace :i18n do
namespace :js do
task export: :environment do
GenerateLocales.generate
end
desc 'Delete all of the generated Javascript locales files'
task clear: :environment do
locales_dir = Rails.root.join('app', 'javascript', 'i18n', 'locales')
FileUtils.remove_dir(locales_dir) if Dir.exists? locales_dir
end
end
end

View file

@ -9,16 +9,17 @@
"build-all": "yarn install --frozen-lockfile && script/compile-assets.sh && yarn build",
"ci-build-all": "script/compile-assets.sh && yarn build",
"test": "bin/rails spec && yarn jest",
"jest": "jest",
"jest": "bin/rails i18n:js:export && jest",
"eslint": "eslint . --ext .ts,.js,.es6,.tsx",
"storybook": "start-storybook -p 6006 -c .storybook/react",
"build-storybook": "build-storybook -c .storybook/react",
"storybook": "bin/rails i18n:js:export && start-storybook -p 6006 -c .storybook/react",
"build-storybook": "bin/rails i18n:js:export && build-storybook -c .storybook/react",
"html-storybook": "bin/start-html-storybook -p 6007 -c .storybook/html",
"build-html-storybook": "bin/build-html-storybook -c .storybook/html",
"markdownlint": "npx markdownlint-cli **/*.md --ignore node_modules",
"prepare-for-push": "yarn test && yarn eslint --fix && yarn markdownlint --fix && bin/rails notice:update",
"prepare-for-push-js": "yarn jest && yarn eslint --fix && yarn markdownlint --fix && bin/rails notice:js:update",
"notice:js": "npx @houdiniproject/noticeme@^1.1.0-pre1 -f NOTICE-js -i included.json -s 250"
"notice:js": "npx @houdiniproject/noticeme@^1.1.0-pre1 -f NOTICE-js -i included.json -s 250",
"webpack": "bin/rails i18n:js:export && bin/webpack"
},
"devDependencies": {
"@babel/core": "^7.0.0",
@ -46,6 +47,7 @@
"@types/enzyme-to-json": "^1.5.1",
"@types/es6-promise": "^3.3.0",
"@types/hoist-non-react-statics": "^3.3.1",
"@types/i18n-js": "^3.0.3",
"@types/jest": "^26.0.14",
"@types/jquery": "^3.3.1",
"@types/jsdom": "^11.0.4",
@ -179,39 +181,5 @@
"vvvview": "0.4.3",
"websocket-extensions": "^0.1.4",
"yup": "^0.29.3"
},
"jest": {
"testEnvironment": "jest-environment-jsdom-fifteen",
"testEnvironmentOptions": {
"enzymeAdapter": "react16"
},
"globals": {
"ts-jest": {
"babelConfig": false
}
},
"setupFiles": [
"<rootDir>/setupTests.js"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testPathIgnorePatterns": [
"/node_modules/",
"/config/webpack/test.js",
"/vendor/"
],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
}
}

View file

@ -3159,6 +3159,11 @@
resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.0.tgz#551a4589b6ee2cc9c1dff08056128aec29b94880"
integrity sha512-iYCgjm1dGPRuo12+BStjd1HiVQqhlRhWDOQigNxn023HcjnhsiFz9pc6CzJj4HwDCSQca9bxTL4PxJDbkdm3PA==
"@types/i18n-js@^3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/i18n-js/-/i18n-js-3.0.3.tgz#84f66fb969741fecd91b854387e0682aa7fd70b7"
integrity sha512-GiZzazvxQ5j+EA4Zf4MtDsSaokAR/gW7FxxTlHi2p2xKFUhwAUT0B/MB8WL77P1TcqAO3MefWorFFyZS8F7s0Q==
"@types/invariant@^2.2.31":
version "2.2.33"
resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.33.tgz#ec5eec29c63bf5e4ca164e9feb3ef7337cdcbadb"