Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can use for extract strings not translated into XREngine repo? #54

Open
johnfelipe opened this issue Jun 8, 2022 · 10 comments
Open

Comments

@johnfelipe
Copy link

https://github.com/XRFoundation/XREngine
pls give me cheatsheet for use your app
commands and paths pls

@lukasgeiter
Copy link
Owner

I'm not sure what exactly you're looking for. I recommend you read the wiki.
If you have a question or problem, provide more details and I'll try my best to help you.

@johnfelipe
Copy link
Author

i want to extract strings not translated yet of https://github.com/XRFoundation/XREngine, i follow this steps

sudo su
cd

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update && sudo apt-get install yarn

# Yarn version
yarn --version
1.22.19

git clone https://github.com/lukasgeiter/gettext-extractor.git
cd gettext-extractor/

yarn add gettext-extractor

yarn test

yarn run v1.22.19
$ jest --config jest.json
 PASS  tests/html/selector.test.ts
 PASS  tests/js/extractors/factories/callExpression.test.ts
 PASS  tests/builder.test.ts
 PASS  tests/utils/content.test.ts
 PASS  tests/js/extractors/comments.test.ts
 PASS  tests/extractor.test.ts
 PASS  tests/html/extractors/factories/elementContent.test.ts
 PASS  tests/html/extractors/factories/elementAttribute.test.ts
 PASS  tests/parser.test.ts
 PASS  tests/html/parser.test.ts
 PASS  tests/js/parser.test.ts
 PASS  tests/js/utils.test.ts
 PASS  tests/html/utils.test.ts
 PASS  tests/html/extractors/factories/embeddedJs.test.ts

Test Suites: 14 passed, 14 total
Tests:       1003 passed, 1003 total
Snapshots:   0 total
Time:        6.899 s
Ran all test suites.
Done in 7.70s.

but i dont know how test in XREngine, pls guide me

@lukasgeiter
Copy link
Owner

First of all, I'm not sure that my package is what you need. gettext-extractor is for the gettext system of managing translations. The extractor generates a .pot template file which is the basis for translations that are stored in .po files. Looking at your repo, I noticed that you're using json for your translations.

@johnfelipe
Copy link
Author

johnfelipe commented Jun 8, 2022 via email

@lukasgeiter
Copy link
Owner

  1. Install the package in your repo (instructions here)
  2. Create a new .js file with the contents from this example
  3. Execute your file using node

At this point you should see some console output and it will generate a messages.pot file that's most likely pretty empty. Why is it empty? Because you haven't adjusted the configuration to your needs yet. You do that by adjusting the code you copied from the example. All necessary information is in the wiki.

@johnfelipe
Copy link
Author

johnfelipe commented Jun 8, 2022 via email

@lukasgeiter
Copy link
Owner

No

@johnfelipe
Copy link
Author

  1. Install the package in your repo (instructions here)
  2. Create a new .js file with the contents from this example
  3. Execute your file using node

At this point you should see some console output and it will generate a messages.pot file that's most likely pretty empty. Why is it empty? Because you haven't adjusted the configuration to your needs yet. You do that by adjusting the code you copied from the example. All necessary information is in the wiki.

root@ubuntu21:~/XREngine# node extraccion.js

  0 messages extracted
  --------------------------
  0 total usages
  0 files (0 with messages)
  0 message contexts

@johnfelipe
Copy link
Author

import React, { useEffect, useState } from 'react'
import { RouteComponentProps } from 'react-router-dom'

import { useProjectState } from '@xrengine/client-core/src/common/services/ProjectService'
import { useDispatch } from '@xrengine/client-core/src/store'
import { useAuthState } from '@xrengine/client-core/src/user/services/AuthService'
import { UserId } from '@xrengine/common/src/interfaces/UserId'
import { Engine } from '@xrengine/engine/src/ecs/classes/Engine'
import { initSystems } from '@xrengine/engine/src/ecs/functions/SystemFunctions'
import { useWorld } from '@xrengine/engine/src/ecs/functions/SystemHooks'
import { SystemUpdateType } from '@xrengine/engine/src/ecs/functions/SystemUpdateType'
import { initializeCoreSystems, initializeSceneSystems } from '@xrengine/engine/src/initializeEngine'
import { loadEngineInjection } from '@xrengine/projects/loadEngineInjection'

import EditorContainer from '../components/EditorContainer'
import { EditorAction, useEditorState } from '../services/EditorServices'

export const EditorPage = (props: RouteComponentProps<{ sceneName: string; projectName: string }>) => {
  const editorState = useEditorState()
  const projectState = useProjectState()
  const authState = useAuthState()
  const dispatch = useDispatch()
  const authUser = authState.authUser
  const user = authState.user
  const [clientInitialized, setClientInitialized] = useState(false)
  const [engineReady, setEngineReady] = useState(false)
  const [isAuthenticated, setAuthenticated] = useState(false)

  const systems = [
    {
      systemModulePromise: import('../systems/RenderSystem'),
      type: SystemUpdateType.POST_RENDER,
      args: { enabled: true }
    },
    {
      systemModulePromise: import('../systems/InputSystem'),
      type: SystemUpdateType.PRE_RENDER,
      args: { enabled: true }
    },
    {
      systemModulePromise: import('../systems/FlyControlSystem'),
      type: SystemUpdateType.PRE_RENDER,
      args: { enabled: true }
    },
    {
      systemModulePromise: import('../systems/EditorControlSystem'),
      type: SystemUpdateType.PRE_RENDER,
      args: { enabled: true }
    },
    {
      systemModulePromise: import('../systems/EditorCameraSystem'),
      type: SystemUpdateType.PRE_RENDER,
      args: { enabled: true }
    },
    {
      systemModulePromise: import('../systems/ResetInputSystem'),
      type: SystemUpdateType.PRE_RENDER,
      args: { enabled: true }
    },
    {
      systemModulePromise: import('../systems/GizmoSystem'),
      type: SystemUpdateType.PRE_RENDER,
      args: { enabled: true }
    }
  ]

  useEffect(() => {
    const _isAuthenticated =
      authUser.accessToken.value != null && authUser.accessToken.value.length > 0 && user.id.value != null

    if (isAuthenticated !== _isAuthenticated) setAuthenticated(_isAuthenticated)
  }, [authUser.accessToken, user.id, isAuthenticated])

  useEffect(() => {
    if (engineReady) {
      const { projectName, sceneName } = props.match.params
      dispatch(EditorAction.projectChanged(projectName ?? null))
      dispatch(EditorAction.sceneChanged(sceneName ?? null))
    }
  }, [engineReady, props.match.params.projectName, props.match.params.sceneName])

  useEffect(() => {
    if (clientInitialized || projectState.projects.value.length <= 0) return
    setClientInitialized(true)
    Engine.instance.isEditor = true
    const world = Engine.instance.currentWorld
    initializeCoreSystems().then(async () => {
      initSystems(world, systems)
      await initializeSceneSystems()
      const projects = projectState.projects.value.map((project) => project.name)
      await loadEngineInjection(world, projects)
      setEngineReady(true)
    })
  }, [projectState.projects.value])

  return <>{engineReady && editorState.projectName.value && isAuthenticated && <EditorContainer />}</>
}

@lukasgeiter
Copy link
Owner

Again, read this wiki page and try figuring things out on your own. I'm not going to do your work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants