translate 相关问题

翻译意味着将用一种语言编写的程序转换为用另一种语言编写的语义上等效的程序,通常是较低级别的语言。

将带有yield(string)的python函数翻译为C++

我正在将Python函数翻译成C++函数;这个函数使用了一个yield(string)语句,我不知道如何翻译。 整个故事在这里......我有一个特定的函数可以读取

回答 5 投票 0

在 openGL 中使用索引缓冲区绘制立方体

#包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #include <stdio.h> #include <stdlib.h> #include <string> #include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <GL/glew.h> #include <GL/glut.h> #include <GL/glm/glm.hpp> #include <GL/glm/gtx/transform.hpp> // rotate(), scale(), translate() #include <GL/glm/gtc/quaternion.hpp> #include <GL/glm/gtc/type_ptr.hpp> using namespace std; GLuint VertexArrayID; GLuint programID; float sx = 0; float sy = 0; bool projMode = true; // true: perspective, false: ortho GLuint LoadShaders(const char* vertex_file_path, const char* fragment_file_path) { //create the shaders GLuint VertexShaderID = glCreateShader(GL_VERTEX_SHADER); GLuint FragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER); GLint Result = GL_FALSE; int InfoLogLength; //Read the vertex shader code from the file string VertexShaderCode; ifstream VertexShaderStream(vertex_file_path, ios::in); if (VertexShaderStream.is_open()) { string Line = ""; while (getline(VertexShaderStream, Line)) VertexShaderCode += "\n" + Line; VertexShaderStream.close(); } //Compile Vertex Shader printf("Compiling shader : %s\n", vertex_file_path); char const* VertexSourcePointer = VertexShaderCode.c_str(); glShaderSource(VertexShaderID, 1, &VertexSourcePointer, NULL); glCompileShader(VertexShaderID); //Check Vertex Shader glGetShaderiv(VertexShaderID, GL_COMPILE_STATUS, &Result); glGetShaderiv(VertexShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength); if (InfoLogLength > 0) { vector<char> VertexShaderErrorMessage(InfoLogLength); glGetShaderInfoLog(VertexShaderID, InfoLogLength, NULL, &VertexShaderErrorMessage[0]); fprintf(stdout, "%s\n", &VertexShaderErrorMessage[0]); } //Read the fragment shader code from the file string FragmentShaderCode; ifstream FragmentShaderStream(fragment_file_path, ios::in); if (FragmentShaderStream.is_open()) { string Line = ""; while (getline(FragmentShaderStream, Line)) FragmentShaderCode += "\n" + Line; FragmentShaderStream.close(); } //Compile Fragment Shader printf("Compiling shader : %s\n", fragment_file_path); char const* FragmentSourcePointer = FragmentShaderCode.c_str(); glShaderSource(FragmentShaderID, 1, &FragmentSourcePointer, NULL); glCompileShader(FragmentShaderID); //Check Fragment Shader glGetShaderiv(FragmentShaderID, GL_COMPILE_STATUS, &Result); glGetShaderiv(FragmentShaderID, GL_INFO_LOG_LENGTH, &InfoLogLength); if (InfoLogLength > 0) { vector<char> FragmentShaderErrorMessage(InfoLogLength); glGetShaderInfoLog(FragmentShaderID, InfoLogLength, NULL, &FragmentShaderErrorMessage[0]); fprintf(stdout, "%s\n", &FragmentShaderErrorMessage[0]); } //Link the program fprintf(stdout, "Linking program\n"); GLuint ProgramID = glCreateProgram(); glAttachShader(ProgramID, VertexShaderID); glAttachShader(ProgramID, FragmentShaderID); glLinkProgram(ProgramID); // Check the program glGetProgramiv(ProgramID, GL_LINK_STATUS, &Result); glGetProgramiv(ProgramID, GL_INFO_LOG_LENGTH, &InfoLogLength); vector<char> ProgramErrorMessage(max(InfoLogLength, int(1))); glGetProgramInfoLog(ProgramID, InfoLogLength, NULL, &ProgramErrorMessage[0]); fprintf(stdout, "%s\n", &ProgramErrorMessage[0]); glDeleteShader(VertexShaderID); glDeleteShader(FragmentShaderID); return ProgramID; } void renderScene(void) { //Clear all pixels glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Let's draw something here glBindVertexArray(VertexArrayID); //define the size of point and draw a point. glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0); //Double buffer glutSwapBuffers(); } void mouse(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { projMode = !projMode; } } void init() { //initilize the glew and check the errors. GLenum res = glewInit(); if (res != GLEW_OK) { fprintf(stderr, "Error: '%s' \n", glewGetErrorString(res)); } //select the background color glClearColor(1.0, 1.0, 1.0, 1.0); glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glDepthRange(0.0f, 1.0f); } GLfloat cubeVertices[] = { // front -0.1f, 0.1f, 0.1f, -0.1f,-0.1f, 0.1f, 0.1f,-0.1f, 0.1f, 0.1f, 0.1f, 0.1f, -0.1f, 0.1f, 0.1f, 0.1f,-0.1f, 0.1f, // back 0.1f, 0.1f,-0.1f, -0.1f,-0.1f,-0.1f, -0.1f, 0.1f,-0.1f, 0.1f, 0.1f,-0.1f, 0.1f,-0.1f,-0.1f, -0.1f,-0.1f,-0.1f, // left -0.1f,-0.1f,-0.1f, -0.1f,-0.1f, 0.1f, -0.1f, 0.1f, 0.1f, -0.1f,-0.1f,-0.1f, -0.1f, 0.1f, 0.1f, -0.1f, 0.1f,-0.1f, // right 0.1f, 0.1f, 0.1f, 0.1f,-0.1f,-0.1f, 0.1f, 0.1f,-0.1f, 0.1f,-0.1f,-0.1f, 0.1f, 0.1f, 0.1f, 0.1f,-0.1f, 0.1f, // bottom 0.1f,-0.1f, 0.1f, -0.1f,-0.1f,-0.1f, 0.1f,-0.1f,-0.1f, 0.1f,-0.1f, 0.1f, -0.1f,-0.1f, 0.1f, -0.1f,-0.1f,-0.1f, // top 1.1f, 0.1f, 0.1f, 0.1f, 0.1f,-0.1f, -0.1f, 0.1f,-0.1f, 0.1f, 0.1f, 0.1f, -0.1f, 0.1f,-0.1f, -0.1f, 0.1f, 0.1f, }; GLfloat cubeColors[] = { // red 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, // green 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, // blue 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, // yellow 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, // cyan 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, // magenta 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, }; /* idx | coord: 0 | (1,1,1) 1 | (-1, 1, 1) 2 | (-1,-1,1) 3 | (1, -1, 1) 4 | (1, -1, -1) 5 | (1, 1, -1) 6 | (-1, 1, -1) 7 | (-1, -1, -1) */ GLfloat cubeIndices[] = { // front 0, 1, 2, 0, 1, 3, // back 5, 6, 7, 5, 6, 4, // left 1, 2, 6, 1, 2, 7, // right 0, 3, 4, 0, 4, 5, // top 0, 1, 5, 0, 1, 6, // bottom 2, 3, 4, 2, 4, 7, }; int main(int argc, char** argv) { //init GLUT and create Window //initialize the GLUT glutInit(&argc, argv); //GLUT_DOUBLE enables double buffering (drawing to a background buffer while the other buffer is displayed) glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); //These two functions are used to define the position and size of the window. glutInitWindowPosition(200, 200); glutInitWindowSize(480, 480); //This is used to define the name of the window. glutCreateWindow("Simple OpenGL Window"); //call initization function init(); //0. programID = LoadShaders("VertexShader.txt", "FragmentShader.txt"); glUseProgram(programID); /**************************************************/ // model matrix glm::mat4 model = glm::mat4(1.0f); float rotateAngle = 45.0f; glm::vec3 rotateAxis(0.0f, 1.0f, 0.0f); model = glm::rotate(model, glm::radians(rotateAngle), rotateAxis); glm::vec3 scaleVec(5.0f, 5.0f, 5.0f); model = glm::scale(model, scaleVec); glm::vec3 translateVec(0.0f, 0.0f, 0.0f); model = glm::translate(model, translateVec); // view matrix glm::mat4 view = glm::lookAt(glm::vec3(5.0f, -5.0f, -5.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f)); // proj matrix glm::mat4 proj; int width = glutGet(GLUT_WINDOW_WIDTH); int height = glutGet(GLUT_WINDOW_HEIGHT); if (projMode) { float aspectRatio = float(width) / height; proj = glm::perspective(glm::radians(45.0f), aspectRatio, 0.1f, 100.0f); } else { float orthoSize = 5.0f; proj = glm::ortho(-orthoSize, orthoSize, -orthoSize, orthoSize, 0.1f, 0.6f); } // model, view, proj matrix to shader GLint modelLoc = glGetUniformLocation(programID, "model"); glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model)); GLint viewLoc = glGetUniformLocation(programID, "view"); glUniformMatrix4fv(viewLoc, 1, GL_FALSE, glm::value_ptr(view)); GLint projLoc = glGetUniformLocation(programID, "proj"); glUniformMatrix4fv(projLoc, 1, GL_FALSE, glm::value_ptr(proj)); /**************************************************/ glGenVertexArrays(1, &VertexArrayID); glBindVertexArray(VertexArrayID); float vtxs[] = { -0.5, 0.0, 0.0, 0.5, 0.3, 0.0 }; GLuint VBOs[3]; glGenBuffers(3, VBOs); glBindBuffer(GL_ARRAY_BUFFER, VBOs[0]); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 3 * 3 * 2 * 6, cubeVertices, GL_STATIC_DRAW); GLuint posAttribLoc = glGetAttribLocation(programID, "inPos"); glVertexAttribPointer(posAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(0)); glEnableVertexAttribArray(posAttribLoc); glBindBuffer(GL_ARRAY_BUFFER, VBOs[1]); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4 * 3 * 2 * 6, cubeColors, GL_STATIC_DRAW); GLuint colAttribLoc = glGetAttribLocation(programID, "color"); glVertexAttribPointer(colAttribLoc, 4, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(0)); glEnableVertexAttribArray(colAttribLoc); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, VBOs[2]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(float) * 6 * 6, cubeIndices, GL_STATIC_DRAW); GLuint idxAttribLoc = glGetAttribLocation(programID, "index"); glVertexAttribPointer(idxAttribLoc, 3, GL_FLOAT, GL_FALSE, 0, (GLvoid*)(0)); glEnableVertexAttribArray(idxAttribLoc); glutDisplayFunc(renderScene); glutMouseFunc(mouse); //enter GLUT event processing cycle glutMainLoop(); glDeleteVertexArrays(1, &VertexArrayID); return 1; } 我想用上面的代码绘制一个 3D 立方体,但我得到一个白色的窗口。如何在窗口上显示 3D 立方体? 如果我对 VBO 和 IBO 使用像“VBOs”这样的数组,如上面的代码所示,会出现问题吗? 另外,你能告诉我如何绘制多个立方体吗? 最后,如果您告诉我我的代码中还有其他问题,我将非常感谢您。 我是一个完全的初学者,说实话,我并不完全理解图形管道。但我真的很感谢你对我的作业的帮助。 type的参数glDrawElements为整数1。 您已将索引定义为实数数组: GLfloat cubeIndices[] = { // front 0, 1, 2, 因此,当 glDrawElements 工作并读取 cubeIndices 的内存时,它会遇到一些巨大的值(例如,整数值 1 作为浮点数为 0x3f80'0000)。您定义的索引完全不在顶点属性数组确定的范围内。

回答 1 投票 0

将 C# LINQ 查询转换为 VB

我正在尝试将一些代码从 C# 转换为 VB.NET,以查找一组特定的类成员,除了使用一些 C# 的一点 LINQ 查询外,我几乎已经完全解决了问题

回答 1 投票 0

我希望当我通过 PhantomJS 加载页面 HTML 时执行我的 JS

我正在尝试加载 HTML,直到执行 JS 代码以使用 PHP 翻译 HTML。然后我想检索这个翻译后的 HTML 的内容。我做了很多研究,但我无法理解......

回答 1 投票 0

加载我的 HTML,直到我的 JS 代码使用 PHP 对其进行翻译

我正在尝试加载 HTML,直到我的 JS 代码使用 PHP 对其进行翻译。然后我想检索这个翻译后的 HTML 的内容。我做了很多研究,但我似乎做不到。 这是...

回答 1 投票 0

如何使用 Python 中的 Microsoft 翻译 API 将文本从一种语言转换为另一种语言?

我正在尝试开发一个多语言聊天应用程序,它可以使用Python将文本从一种语言转换为另一种语言。 我尝试了几种解决方案,并找到了 Microsoft Bing Transla...

回答 2 投票 0

如何使用 Python 使用 Microsoft Translate API 将文本从一种语言转换为另一种语言?

我正在尝试开发一个多语言聊天应用程序,它可以使用Python将文本从一种语言转换为另一种语言。 我尝试了几种解决方案,并找到了 Microsoft Bing Transla...

回答 2 投票 0

使用 Microsoft Translate API 将文本从一种语言转换为另一种语言的 Python 代码

我正在尝试开发一个多语言聊天应用程序,它可以使用Python将文本从一种语言转换为另一种语言。 我尝试了几种解决方案,并找到了 Microsoft Bing Translat...

回答 2 投票 0

是否可以使用 Chrome 的 API 翻译 Chrome 扩展程序中的文本?

我正在开发一个 chrome 扩展,需要在不同语言之间翻译文本。我宁愿避免对付费服务进行外部 API 调用,例如 Google Translation API 和...

回答 1 投票 0

使用 Google Cloud Translation API 翻译完整网页

需要使用 Google Cloud Translation API 翻译整个网页,而不仅仅是某些文本。 (文档:https://cloud.google.com/translate/docs/overview)。我该如何继续构建这个?该...

回答 1 投票 0

如何使用动画 html css 保持悬停状态 w

我需要在动画单击时保持悬停状态。 当我将鼠标悬停在父 div 上时,子元素应该转换为 -10px,我需要在单击父元素时保持转换 -10px ...

回答 1 投票 0

如何将卡纳达语文本从 pdf 或 word 文档复制粘贴到谷歌翻译文本字段?

我有一份用卡纳达语编写的文档,有 pdf 格式和 doc 格式。它是可读的。但是,如果我将其中的一些文本复制粘贴到谷歌翻译文本字段(手动将语言设置为卡纳达语),它

回答 1 投票 0

翻译段落,包括链接

我正在制作一个可以更改语言的网站。我在其他网页的链接中添加了一些单词来解释该单词的含义,请参阅下面的代码。 我正在制作一个可以更改语言的网站。我在其他网页的链接中添加了一些单词来解释该单词的含义,请参阅下面的代码。 <h4 class="critTitle">Critical infrastructure security</h4> <p class="crit">Critical infrastructure security addresses the protection of computer systems, applications, networks, data and digital assets that are critical to a society's national security, economic health and public safety. In the United States, the <a href="https://www.nist.gov/">National Institute of Standards and Technology</a> (NIST) has developed a cybersecurity framework to support IT vendors in this area. In addition, the U.S. Department of Homeland Security's Cybersecurity and Infrastructure Security Agency (CISA) provides additional guidance to strengthen the security of critical infrastructures.</p> <div class="language"> <div class="langWrap"> <a href="#" language='english' class="lang active">EN</a> <a href="#" language='spanish' class="lang">ES</a> </div> </div> 下面的代码显示了我如何翻译文本。 const langEl = [...document.querySelectorAll(".lang")]; const critTitleEl = document.querySelector(".critTitle"); const critEl = document.querySelector(".crit"); langEl.forEach((el) => { el.addEventListener("click", () => { langEl.map(item => item.classList.contains("active") ? item.classList.remove("active") : false); el.classList.add("active"); chosenLanguage = el.innerText; search(); const attr = el.getAttribute("language"); critTitleEl.textContent = data[attr].critTitle; critEl.textContent = data[attr].crit; }); var data = { english: { critTitle: "Critical infrastructure security", crit: "Critical infrastructure security addresses the protection of computer systems, applications, networks, data and digital assets that are critical to a society's national security, economic health and public safety. In the United States, the National Institute of Standards and Technology (NIST) has developed a cybersecurity framework to support IT vendors in this area. In addition, the U.S. Department of Homeland Security's Cybersecurity and Infrastructure Security Agency (CISA) provides additional guidance to strengthen the security of critical infrastructures." }, spanish: { critTitle: "Seguridad de las infraestructuras críticas", crit: "La seguridad de las infraestructuras críticas se centra en la protección de sistemas informáticos, aplicaciones, redes, datos y activos digitales que son fundamentales para la seguridad nacional, la salud económica y la seguridad pública de una sociedad. En Estados Unidos, el Instituto Nacional de Normas y Tecnología (NIST) ha desarrollado un marco de ciberseguridad para apoyar a los proveedores de TI en este ámbito. Además, la Agencia de Ciberseguridad y Seguridad de las Infraestructuras (CISA) del Departamento de Seguridad Nacional de EE.UU. ofrece orientaciones adicionales para reforzar la seguridad de las infraestructuras críticas." } 问题是链接在翻译后消失,因为它变成了字符串。是否可以使链接保持不变并且不会更改为字符串? 这里您需要使用critEl.textContent而不是critEl.innerHTML,因此html代码将被替换。并且您的 crit 内部数据需要包含 <a... 检查:在此处更新您的

回答 1 投票 0

定位旋转图标

我有一段代码,我无法理解它,我需要帮助。 我有几个图标,我希望它们绕圈旋转,同时保持笔直并且不围绕它们旋转......

回答 1 投票 0

导师mfe为价值打开了x翻译

我可以翻译导师mfe的帐户页面,但我想要用户名下的值也应该翻译成印地语。任何人请帮助我如何做到这一点 我已经按照这个过程进行了

回答 1 投票 0

翻译行为和相关模型翻译

我在网上搜索了1000000000000000次,但找不到一个干净的解决方案 这是我的CertificateType模型翻译部分: public $actsAs = array('翻译'=>array('标题','描述...

回答 7 投票 0

翻译后的对象不可迭代

我正在尝试制作一个程序,可以翻译您用瑞典语所说的任何内容,并使用 PyAutoGUI Typewrites 它。但是当我运行代码时,我得到了同样的错误。 trans=翻译器() 翻译文本=输入(...

回答 2 投票 0

tr翻译带有66和99引号“ ”的字符问题

我正在使用命令 tr 来删除标点符号,但它似乎并没有删除 66 和 99 类型的引号。 这是我使用的命令: 猫测试.txt | tr '[:punct:]' ' ' 这些 : ” ” 确实如此

回答 1 投票 0

如何根据设备语言更改Flutter中Map中的String文本?

我正在 Flutter 中制作一个应用程序,有一些图像卡,当你单击这些图像时,你会转到另一个页面,你会得到有关该图像的描述,我通过

回答 1 投票 0

React - 如何更改Material ui的DataTable组件属性的语言?

我正在使用名为 DataTable 的 Material ui 组件,问题是过滤器字段是英语,我想知道是否有任何方法可以将其语言更改为葡萄牙语 在我的组件下面...

回答 4 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.