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

Little concern about language translation #1274

Closed
kukrik opened this issue Jul 17, 2017 · 6 comments
Closed

Little concern about language translation #1274

kukrik opened this issue Jul 17, 2017 · 6 comments

Comments

@kukrik
Copy link
Member

kukrik commented Jul 17, 2017

Previously, there was a bad situation where the translation code was not supported.
We was to do a lot of crafts.
There is a much better situation right now. It's very easy to add if needed, for example, one example:

public function __toString() {
        return sprintf('%s',  $this->strName);
}

to

public function __toString() {
	return sprintf(QApplication::Translate('%s'),  $this->strName);
}

Or in other places that were easy to add. At the _type table, I had difficulty translating. I went on a mild resistance path, I wrote directly into my mother tongue. But this is not the right solution, because multi-lingual support is needed.

I found one solution for the list only:

public static function ToString($intProjectStatusTypeId) {
	switch ($intProjectStatusTypeId) {
		case 1: return 'Open';
		case 2: return 'Cancelled';
		case 3: return 'Completed';
			default:
				throw new QCallerException(sprintf('Invalid intProjectStatusTypeId: %s', $intProjectStatusTypeId));
			}
		}

to

public static function ToString($intProjectStatusTypeId) {
	switch ($intProjectStatusTypeId) {
		case 1: return QApplication::Translate('Open');
		case 2: return QApplication::Translate('Cancelled');
		case 3: return QApplication::Translate('Completed');
			default:
				throw new QCallerException(sprintf('Invalid intProjectStatusTypeId: %s', $intProjectStatusTypeId));
			}
		}

But the translation works only in the list. The form listbox does not show translation support, more precisely at code level:

	/**
		 * Create and setup QListBox lstProjectStatusType
		 * @param string $strControlId optional ControlId to use
		 * @return QListBox
		 */

		public function lstProjectStatusType_Create($strControlId = null) {
			$this->lstProjectStatusType = new QListBox($this->objParentObject, $strControlId);
			$this->lstProjectStatusType->Name = QApplication::Translate('Project Status Type');
			$this->lstProjectStatusType->Required = true;
			$this->lstProjectStatusType->PreferredRenderMethod = 'RenderWithName';
			$this->lstProjectStatusType->LinkedNode = QQN::Project()->ProjectStatusTypeId;
            if (!$this->strProjectStatusTypeNullLabel) {
            	if (!$this->lstProjectStatusType->Required) {
            		$this->strProjectStatusTypeNullLabel = '- None -';
            	}
            	elseif (!$this->blnEditMode) {
            		$this->strProjectStatusTypeNullLabel = '- Select One -';
            	}
            }
            $this->lstProjectStatusType->AddItem(QApplication::Translate($this->strProjectStatusTypeNullLabel), null);
            $this->lstProjectStatusType->AddItems($this->lstProjectStatusType_GetItems());
            $this->lstProjectStatusType->SelectedValue = $this->objProject->ProjectStatusTypeId;
			return $this->lstProjectStatusType;
		}

		/**
		 *	Create item list for use by lstProjectStatusType
		 */
		public function lstProjectStatusType_GetItems() {
			return ProjectStatusType::$NameArray;
		}

I've been looking for a solution for a long time, but I have not found a better deal. Do you have better thoughts or solutions? Or, the _type table translation option is excluded?

I put one screenshot here:
translation_question

Thanks in advance!

@spekary
Copy link
Member

spekary commented Jul 17, 2017

You are right that translation hasn't been well supported in the past. I consider those listbox problems as bugs in the code generation templates. Those should be easy to fix.

For version 4, translation is going to be handled in a separate repo - the i18n repo. It has mechanisms so that every repo can translate itself.

@spekary
Copy link
Member

spekary commented Jul 18, 2017

Please test to see if this fixes the problems you described.

@kukrik
Copy link
Member Author

kukrik commented Jul 20, 2017

I did a test. It's good at the beginning, the list shows translations well, but in the edit mode the ListBox does not show translations :(.

I also looked at UnitTest. I do not know if they are interrelated. Anyway, I'll put error messages here:

Failed: testTypes
Failed asserting that two strings are equal.
/Users/Papikodu/Documents/WEB/qcubed-3.1.1/vendor/qcubed/qcubed/includes/tests/qcubed-unit/BasicOrmTest.php:503

Failed: testReference
Failed asserting that false is true.
/Users/Papikodu/Documents/WEB/qcubed-3.1.1/vendor/qcubed/qcubed/includes/tests/qcubed-unit/ModelConnectorTest.php:75

Failed: testOverrides
Street Label was removed by override.
Failed asserting that false is true.
/Users/Papikodu/Documents/WEB/qcubed-3.1.1/vendor/qcubed/qcubed/includes/tests/qcubed-unit/ModelConnectorTest.php:196

Failed: testAjaxChangeFormState
Events can block later events until a response is received.
Failed asserting that false is true.
/Users/Papikodu/Documents/WEB/qcubed-3.1.1/vendor/qcubed/qcubed/includes/tests/qcubed-unit/QControlBaseTest.php:132

@spekary, how are we going?

@kukrik
Copy link
Member Author

kukrik commented Jul 20, 2017

As far as I think, $NameArray is the place where the translation function would be needed here:

/**
		 *	Create item list for use by lstProjectStatusType
		 */
		public function lstProjectStatusType_GetItems() {
			return ProjectStatusType::$NameArray;
		}

@kukrik
Copy link
Member Author

kukrik commented Jul 20, 2017

Here I found that the translation function has been redrawn multiple times, which is not needed:

                 /**
		 * Create and setup QListBox lstProjectStatusType
		 * @param string $strControlId optional ControlId to use
		 * @return QListBox
		 */

		public function lstProjectStatusType_Create($strControlId = null) {
			$this->lstProjectStatusType = new QListBox($this->objParentObject, $strControlId);
			$this->lstProjectStatusType->Name = QApplication::Translate('Project Status Type');
			$this->lstProjectStatusType->Required = true;
			$this->lstProjectStatusType->PreferredRenderMethod = 'RenderWithName';
			$this->lstProjectStatusType->LinkedNode = QQN::Project()->ProjectStatusTypeId;
            if (!$this->strProjectStatusTypeNullLabel) {
            	if (!$this->lstProjectStatusType->Required) {
            		$this->strProjectStatusTypeNullLabel = QApplication::Translate('- None -');
            	}
            	elseif (!$this->blnEditMode) {
            		$this->strProjectStatusTypeNullLabel = QApplication::Translate('- Select One -');
            	}
            }
            $this->lstProjectStatusType->AddItem(QApplication::Translate($this->strProjectStatusTypeNullLabel), null);
            $this->lstProjectStatusType->AddItems($this->lstProjectStatusType_GetItems());
            $this->lstProjectStatusType->SelectedValue = $this->objProject->ProjectStatusTypeId;
			return $this->lstProjectStatusType;
		}

@kukrik
Copy link
Member Author

kukrik commented Jul 20, 2017

Now my topic can be closed. Reference: #1277

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