Skip to content

Commit

Permalink
Added formatting option.
Browse files Browse the repository at this point in the history
Bumped version 1.0.0.11.
  • Loading branch information
raspopov committed Mar 26, 2017
1 parent 21af184 commit a7efca9
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 24 deletions.
Binary file modified Polang.rc
Binary file not shown.
35 changes: 25 additions & 10 deletions PolangDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VAL_PO _T("PoPath")
#define VAL_POT _T("PotPath")
#define VAL_WINDOW _T("Window")
#define VAL_PRESERVE _T("Preserve")

// CPolangDlg dialog

Expand All @@ -44,6 +45,7 @@ CPolangDlg::CPolangDlg(CWnd* pParent /*=NULL*/)
, m_hIcon ( theApp.LoadIcon( IDR_MAINFRAME ) )
, m_nOptions ( theApp.GetProfileInt( SETTINGS, VAL_OPTIONS, OPT_POT ) )
, m_nOptionsLast ( OPT_NULL )
, m_bPreserve ( theApp.GetProfileInt( SETTINGS, VAL_PRESERVE, TRUE ) )
{
}

Expand All @@ -67,6 +69,8 @@ void CPolangDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control( pDX, IDC_2_3_SET, m_wnd23Set );

DDX_Radio( pDX, IDC_RADIO1, m_nOptions );
DDX_Check( pDX, IDC_FORMAT, m_bPreserve );
DDX_Control( pDX, IDC_FORMAT, m_wndPreserve );
}

void CPolangDlg::UpdateInterface(int nOptions)
Expand Down Expand Up @@ -130,6 +134,7 @@ void CPolangDlg::UpdateInterface(int nOptions)
m_wnd3File.SetCueBanner( _T("") );
m_wnd3Open.EnableWindow( FALSE );
m_wnd23Set.EnableWindow( FALSE );
m_wndPreserve.EnableWindow( FALSE );
break;

case OPT_PO:
Expand Down Expand Up @@ -161,6 +166,7 @@ void CPolangDlg::UpdateInterface(int nOptions)
m_wnd3File.SetCueBanner( _T("ru_RU.po") );
m_wnd3Open.EnableWindow();
m_wnd23Set.EnableWindow();
m_wndPreserve.EnableWindow( FALSE );
break;

case OPT_LANG:
Expand All @@ -178,6 +184,8 @@ void CPolangDlg::UpdateInterface(int nOptions)
m_wnd1File.EnableFileBrowseButton( _T( "lang" ), LoadString( IDS_LANG_FILES ), OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST );
m_wnd1File.SetWindowText( s1Filename );
m_wnd1File.SetCueBanner( _T( "en_US.lang" ) );
m_wnd1File.EnableWindow( m_bPreserve );
m_wnd1Open.EnableWindow( m_bPreserve );
// Input
m_wnd2Title.SetWindowText( LoadString( IDS_PO_TITLE ) );
m_wnd2File.EnableFileBrowseButton( _T("po"), LoadString( IDS_POEDIT_FILES ), OFN_EXPLORER | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST );
Expand All @@ -192,6 +200,7 @@ void CPolangDlg::UpdateInterface(int nOptions)
m_wnd3File.SetCueBanner( _T( "ru_RU.lang" ) );
m_wnd3Open.EnableWindow();
m_wnd23Set.EnableWindow();
m_wndPreserve.EnableWindow();
break;
}

Expand All @@ -208,6 +217,8 @@ void CPolangDlg::UpdateInterface(int nOptions)
m_wnd2File.SetFolder( TrimFileName( s1Filename ) );
m_wnd3File.SetFolder( TrimFileName( s1Filename ) );
}

theApp.WriteProfileInt( SETTINGS, VAL_PRESERVE, m_bPreserve );
}

BEGIN_MESSAGE_MAP(CPolangDlg, CDialogEx)
Expand All @@ -223,6 +234,7 @@ BEGIN_MESSAGE_MAP(CPolangDlg, CDialogEx)
ON_BN_CLICKED( IDC_3_OPEN, &CPolangDlg::OnBnClicked3Open )
ON_BN_CLICKED( IDC_1_2_SET, &CPolangDlg::OnBnClicked12Set )
ON_BN_CLICKED( IDC_2_3_SET, &CPolangDlg::OnBnClicked23Set )
ON_BN_CLICKED( IDC_FORMAT, &CPolangDlg::OnBnClickedFormat )
END_MESSAGE_MAP()

// CPolangDlg message handlers
Expand Down Expand Up @@ -385,7 +397,7 @@ void CPolangDlg::OnOK()

case OPT_LANG:
// Local.po -> Local.lang
if ( s3Filename.IsEmpty() || ! IsFileName( s2Filename ) )
if ( s3Filename.IsEmpty() || ! IsFileName( s2Filename ) || ( m_bPreserve && ! IsFileName( s1Filename ) ) )
{
AfxMessageBox( IDS_MSG_NO_FILE, MB_OK | MB_ICONEXCLAMATION );
return;
Expand All @@ -397,19 +409,19 @@ void CPolangDlg::OnOK()
return;
}

if ( ! IsFileName( s1Filename ) )
if ( m_bPreserve )
{
// Save in sorted order
if ( ! translations.SaveLang( s3Filename ) )
// Save preserving order
if ( ! translations.LoadLang( s1Filename, false, s3Filename ) )
{
AfxMessageBox( IDS_MSG_LANG_SAVE_ERROR, MB_OK | MB_ICONEXCLAMATION );
return;
}
}
else
{
// Ssve preserving order
if ( !translations.LoadLang( s1Filename, false, s3Filename ) )
// Save in sorted order
if ( ! translations.SaveLang( s3Filename ) )
{
AfxMessageBox( IDS_MSG_LANG_SAVE_ERROR, MB_OK | MB_ICONEXCLAMATION );
return;
Expand Down Expand Up @@ -483,8 +495,6 @@ void CPolangDlg::OnBnClicked3Open()

void CPolangDlg::OnBnClicked12Set()
{
CWaitCursor wc;

UpdateData();

CString s1Filename;
Expand All @@ -498,8 +508,6 @@ void CPolangDlg::OnBnClicked12Set()

void CPolangDlg::OnBnClicked23Set()
{
CWaitCursor wc;

UpdateData();

CString s2Filename;
Expand All @@ -510,3 +518,10 @@ void CPolangDlg::OnBnClicked23Set()

UpdateInterface( m_nOptions );
}

void CPolangDlg::OnBnClickedFormat()
{
UpdateData();

UpdateInterface( m_nOptions );
}
4 changes: 4 additions & 0 deletions PolangDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once

#include "BrowseCtrl.h"
#include "afxwin.h"


// CPolangDlg dialog
Expand Down Expand Up @@ -53,6 +54,8 @@ class CPolangDlg : public CDialogEx
int m_nOptions, m_nOptionsLast;
CRect m_rcInitial;
CToolTipCtrl m_pTips;
BOOL m_bPreserve;
CButton m_wndPreserve;

void UpdateInterface(int nOptions);

Expand All @@ -71,6 +74,7 @@ class CPolangDlg : public CDialogEx
afx_msg void OnBnClicked3Open();
afx_msg void OnBnClicked12Set();
afx_msg void OnBnClicked23Set();
afx_msg void OnBnClickedFormat();

DECLARE_MESSAGE_MAP()
};
48 changes: 34 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# Polang

![Icon](http://www.cherubicsoft.com/_media/projects/polang/polang.png)

Converting PoEdit files (.po) to and from Language files (.lang). This utility can help in translation of .lang-based programs like Minecraft and its mods.


![Screenshot](http://www.cherubicsoft.com/_media/projects/polang/polang-main.png)

## Features

* Convert original en_US.lang file to poEdit template file (.pot). So it's pretty easy to create a new or update an existing translation.
* Merge half-translated .lang-file to yours PoEdit file (.po). So existing work will never lost.
* Convert translated PoEdit file (.po) back to .lang-file.
# Polang

![Icon](http://www.cherubicsoft.com/_media/projects/polang/polang.png)

Converting PoEdit files (.po) to and from Language files (.lang).

This utility can help in translation of .lang-based programs like Minecraft and its mods.


![Screenshot](http://www.cherubicsoft.com/_media/projects/polang/polang-main.png)

## Features

* Convert original en_US.lang file to poEdit template file (.pot). So it's pretty easy to create a new or update an existing translation.
* Merge half-translated .lang-file to yours PoEdit file (.po). So existing work will never lost.
* Convert translated PoEdit file (.po) back to .lang-file preserving formatting of original file.

## Copyright

Copyright (C) 2017 Nikolay Raspopov <<[email protected]>>
https://github.com/raspopov/polang

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Binary file modified resource.h
Binary file not shown.

0 comments on commit a7efca9

Please sign in to comment.