You need to look at the error logs. Maybe enable debug as well.
1 04/02/2025 08:04:25 am
Re: Add credit card as bank account (7 replies, posted in Banking and General Ledger)
2 12/30/2024 06:06:51 pm
Re: Translation using googletranslate (6 replies, posted in Translations)
Hi guys.. I tried to do some enhancements to the script. So I removed the need to hardcore the .po file and the target language,rather will have a prompt for both the input .po and the needed translation language. One will be given a list of supported language. At the same time one will be given the option to replace the translated file or give it a different name. Most importantly it will list the line line number of the original file where the translation has failed, at the same same time it will mention 'Translation Failed' in the resultant file.
As Linux is my main system it works perfectly there, one need to test it in Windows CLI (CMD).
I do have a sexy GUI version of the script but its a little more complicated to set the environment for it to work so I will keep it simple for the public and hard for myself.
Here we go. This is the script.
import os
import re
import time
from deep_translator import GoogleTranslator
from polib import pofile
# Define a regex pattern to match `&` only if it's adjacent to a letter or number
mnemonic_pattern = re.compile(r"(?<=\w)&|&(?=\w)")
# Function to remove mnemonics
def remove_mnemonics(text):
"""Remove `&` if it is adjacent to a letter or number."""
return re.sub(mnemonic_pattern, "", text)
# Function to fetch supported languages from Google Translator
def get_supported_languages():
try:
translator = GoogleTranslator()
return translator.get_supported_languages(as_dict=True)
except Exception as e:
print(f"Error fetching languages: {e}")
return {}
# Function to map msgid to line numbers in the original file
def get_msgid_line_numbers(file_path):
"""Map each msgid to its corresponding line number."""
line_number_mapping = {}
with open(file_path, 'r', encoding='utf-8') as f:
lines = f.readlines()
current_msgid = None
for line_num, line in enumerate(lines, start=1):
if line.startswith('msgid "'):
current_msgid = line.strip()[7:-1] # Remove `msgid "` prefix and trailing `"`
line_number_mapping[current_msgid] = line_num
return line_number_mapping
# Function to translate a .po file
def translate_po_file(file_path, target_language):
try:
po_file = pofile(file_path)
except Exception as e:
print(f"Error loading file: {e}")
return
po_file.metadata['Content-Type'] = 'text/plain; charset=UTF-8'
po_file.metadata['Language'] = target_language
try:
translator = GoogleTranslator(source='auto', target=target_language)
except Exception as e:
print(f"Error initializing translator: {e}")
return
line_number_mapping = get_msgid_line_numbers(file_path)
total_entries = len(po_file)
translated_count = 0
failed_count = 0
failed_translations = []
start_time = time.time()
for i, entry in enumerate(po_file):
print(f"Translating {i + 1}/{total_entries}: {entry.msgid}")
if not entry.msgstr:
try:
translated_text = translator.translate(entry.msgid)
entry.msgstr = remove_mnemonics(translated_text)
print(f"Translated: {entry.msgstr}")
translated_count += 1
except Exception as e:
entry.msgstr = "Translation Failed"
failed_count += 1
line_number = line_number_mapping.get(entry.msgid, 'Unknown')
failed_translations.append((entry.msgid, line_number))
print(f"Failed to translate: {entry.msgid} (Line {line_number}) - Error: {e}")
# progress = int((i + 1) / total_entries * 100)
# print(f"Progress: {progress}%")
# Output file logic
output_filename = f"translated_{target_language}.po"
output_filename = os.path.abspath(output_filename) # Normalize for cross-platform compatibility
if os.path.exists(output_filename):
choice = input(f"The file '{output_filename}' already exists. Overwrite? (y/n): ").strip().lower()
if choice != 'y':
new_filename = input("Enter a new filename: ").strip()
if not new_filename:
print("Translation Cancelled.")
return
output_filename = os.path.abspath(new_filename)
try:
po_content = po_file.__unicode__()
with open(output_filename, 'w', encoding='utf-8') as f:
f.write(po_content)
except Exception as e:
print(f"Error saving file: {e}")
return
end_time = time.time()
elapsed_time = end_time - start_time
hours, rem = divmod(elapsed_time, 3600)
minutes, seconds = divmod(rem, 60)
print("\nTranslation Complete!")
print(f"Total entries: {total_entries}")
print(f"Successfully translated: {translated_count}")
print(f"Failed translations: {failed_count}")
print(f"Elapsed time: {int(hours)}h {int(minutes)}m {int(seconds)}s")
print(f"File saved as: {output_filename}")
if failed_translations:
print("\nFailed Translations:")
for msgid, line_number in failed_translations:
print(f" Line {line_number}: {msgid}")
# Function to validate and get file path
def get_file_path():
while True:
file_path = input("Enter the path to the .po file (or type 'cancel' to exit): ").strip()
if file_path.lower() == 'cancel':
print("Operation cancelled by user.")
return None
if os.path.exists(file_path):
return file_path
print("Error: File does not exist. Please try again.")
# Function to validate and get target language
def get_target_language(languages_dict):
while True:
target_input = input("\nEnter the target language name or code: ").strip().lower()
# Check if it's a valid language code
if target_input in languages_dict.keys():
return target_input
# Check if it's a valid language name
for code, name in languages_dict.items():
if target_input == name.lower():
return code
print("Invalid language input. Please enter a valid language name or code.")
# Main function for CLI
def main():
print("PO File Translator (CLI Version)")
# Get file path
file_path = get_file_path()
if not file_path:
return # User chose to cancel
# Get supported languages
languages_dict = get_supported_languages()
if not languages_dict:
print("Error: Could not fetch supported languages.")
return
# Display supported languages
print("\nSupported Languages:")
for code, lang in languages_dict.items():
print(f"{code}: {lang}")
# Get target language
target_language = get_target_language(languages_dict)
# Translate the file
translate_po_file(file_path, target_language)
if __name__ == "__main__":
main()
3 11/08/2024 03:15:55 pm
Topic: Translation using googletranslate (6 replies, posted in Translations)
I was always interested in online translations. So I asked my friend chatgpt to help me translate empty.po to Arabic just to see how they behave as an AI gurus. They failed saying the best for me is to use googletranslate and they offered me help with a python script. The script that uses googletranslate failed also, so they suggested deep-translate. After many tries and errors I came out with this script. I use Linux Zorin which is a flavour of Ubuntu. So for the script to run one needs to install python3 and the other modules for it to work.
So here we go.
to install python 3
sudo apt install python3
After python 3 installation
pip install deep-translator
And
pip install polib
And here is the script which I called translate.py
import time
import re
from deep_translator import GoogleTranslator
from polib import pofile
# Load the .po file
po_file = pofile('empty.po')
# Update the Content-Type in the header to UTF-8
po_file.metadata['Content-Type'] = 'text/plain; charset=UTF-8'
# Initialize the translator
translator = GoogleTranslator(source='auto', target='ar')
# Define a regex pattern to match `&` before or after an alphanumeric character
mnemonic_pattern = re.compile(r"(?<=\w)&|&(?=\w)")
# Counters for statistics
total_entries = len(po_file)
translated_count = 0
failed_count = 0
# Start the timer
start_time = time.time()
# Process each entry in the .po file
for entry in po_file:
# Translate if msgstr is empty
if not entry.msgstr:
try:
print(f"Translating: {entry.msgid}") # Debug print
translated_text = translator.translate(entry.msgid)
# After translating, remove mnemonics from the translated text
entry.msgstr = re.sub(mnemonic_pattern, "", translated_text)
translated_count += 1
print(f"Translated: {entry.msgstr}") # Debug print
except Exception as e:
print(f"Warning: Failed to translate '{entry.msgid}' due to {e}")
entry.msgstr = "Translation Failed"
failed_count += 1
else:
# If already translated, remove mnemonics from the existing translation
entry.msgstr = re.sub(mnemonic_pattern, "", entry.msgstr)
# Ensure all msgstr values are not None before saving
for entry in po_file:
if entry.msgstr is None:
entry.msgstr = ""
# Calculate the elapsed time
end_time = time.time()
elapsed_time = end_time - start_time
# Convert elapsed time to hours, minutes, and seconds
hours, rem = divmod(elapsed_time, 3600)
minutes, seconds = divmod(rem, 60)
# Save the translated .po file
output_filename = 'translated_arabic.po'
try:
po_file.save(output_filename)
print(f"\nTranslation complete. The file is saved as '{output_filename}'")
except Exception as e:
print(f"Error saving the file: {e}")
# Print translation statistics
print("\n--- Translation Statistics ---")
print(f"Total entries: {total_entries}")
print(f"Successfully translated: {translated_count}")
print(f"Failed to translate: {failed_count}")
print(f"Elapsed time: {int(hours)}h {int(minutes)}m {int(seconds)}s")
In the script I had to get rid of the & keyboard mnemonic as it does not work in any translation and should be changed in the code. i.e &Items is not translatable to what it should do once one presses Alt-I.
The above script is for Arabic as target='ar'
It works for most languages just by specifying the target language. i.e I tried it for Tamil target='ta'. It works. Do not forget to change the output_filename = 'translated_arabic.po' to whatever you like.
To run the scrip
python3 translate.py
As of all online translations its OK at about 70%. The rest is out of context and needs to be edited manually. Thats where one uses poedit to correct the 30%.
Just note. It took 40 minutes for Arabic Translation with 6 errors and 28 minutes for Tamil Translations with no errors. Total strings translated 3498.
4 10/22/2024 01:42:28 am
Re: Experiencing frequent and unexpected logouts from the application (3 replies, posted in Setup)
Its a good idea to mention your environment.
Also
1. Remove Browser cache.
2. Use different browser.
3. https://frontaccounting.com/punbb/viewtopic.php?id=8570
4. Use debug and look into errors.log
5 10/14/2024 03:13:45 am
Re: import csv items (3 replies, posted in Items and Inventory)
Make sure you activate the extension for the company you are working on.
Setup->Install/Activate extensions->Available and/or Installed-> Pull down menu and choose the Company with Activate For 'Name of your Company'.
6 10/04/2024 02:30:01 am
Re: Date Range for Search (2 replies, posted in Accounts Receivable)
Preferences -> Transaction days will increase the search range.
7 06/03/2024 11:49:45 am
Re: Dashboard (8 replies, posted in Installation)
Try with a different theme i.e Default.
8 05/25/2024 07:25:10 am
Re: Trial Balance Format requires some changes (1 replies, posted in Reporting)
There is an extension called Annual Balance Breakdown - Detailed. Try it. You might find what you need in it.
9 05/24/2024 05:32:06 am
Re: Print Item & Kit List (4 replies, posted in Items and Inventory)
1. Inventory Reports might have what you are asking for, unless I misunderstood your requirements.
2. In config.php
Optional popup search enabled if this is true.
$max_rows_in_search = 10 is used for maximum rows in search
*/
$use_popup_search = true;
$max_rows_in_search = 100;
10 05/19/2024 09:46:28 am
Re: Problem with any language other than English not working on the system (7 replies, posted in Translations)
I have to admit Godady is loosing it. Their support is deteriorated. By removing locals they are forcing people to buy dedicated server in order to increase revenue. There is no way to install locales on a shared server even if you have access to a terminal( which I have thru ssh) because most of the commands are disabled.
11 05/15/2024 01:01:07 pm
Re: Problem with any language other than English not working on the system (7 replies, posted in Translations)
@AhmedSelim is correct. GoDaddy removed all locales other than English.
In linux hosting locale -a lists only en_ languages . all others disappeared.
You need to contact GoDaddy and ask them to install ar_EG locale for you.
12 04/03/2024 10:07:16 am
Re: How to update translation (3 replies, posted in Translations)
.../lang/new_language_template/LC_MESSAGES/empty.po has all the translatable strings.
13 01/10/2024 08:32:23 am
Re: Closing equity accounts for start of new year (2 replies, posted in Banking and General Ledger)
IMHO the best way to do what @diventi.enterprises needs is to follow the wiki as in
https://frontaccounting.com/fawiki/index.php?n=Main.TaxSystem
Study whats in Using the Tax System. You will find what you looking for with an example.
14 01/03/2024 12:24:52 pm
Re: Customer Or Supplier Selection By Manually Entering Characters (2 replies, posted in Report Bugs here)
Try Setup>Company Setup and tick Search Customer List and Seach Suppliers List and see if it helps.
15 12/02/2023 10:17:16 am
Re: 2.4.17 Long Descriptions in Sales Invoices (7 replies, posted in Report Bugs here)
https://frontaccounting.com/punbb/viewtopic.php?id=8700
16 11/23/2023 08:03:48 am
Re: Sales Quotation Inquiry is not showing quotations with 0 total amount. (1 replies, posted in Setup)
I recommend you issue a bug report in Mantis. This looks like a bug to me.
17 11/20/2023 06:29:24 am
Re: Urdu language display is not working after upgrading FA to 2.4.17 vers (2 replies, posted in Installation)
@msuhail197
You have already encountered this problem a long time ago as in:
https://frontaccounting.com/punbb/viewtopic.php?id=8220&p=2
How did you resolve it?
Just follow the same route.
18 11/16/2023 06:31:45 pm
Re: Backup/Restore showing Empty Database after backup (2 replies, posted in Setup)
Enable debug and look at the contents of errors.log
19 11/10/2023 12:42:59 am
Re: Import Transactions not working (28 replies, posted in Modules/Add-on's)
Yes it did. For me it did not make sense as the error was coming from outside the Module and I think it is from the core. If you look at it the insert fields do not tally with what is in the csv file. Here is the error:
10-Nov-2023 01:31:32 Europe/Berlin] <b>DATABASE ERROR :</b> order Cannot be Added<br>error code : 1265<br>error message : Data truncated for column 'prep_amount' at row 1<br>sql that failed was : INSERT INTO 0_sales_orders (order_no, type, debtor_no, trans_type, branch_code, customer_ref, reference, comments, ord_date,
order_type, ship_via, deliver_to, delivery_address, contact_phone,
freight_cost, from_stk_loc, delivery_date, payment_terms, total, prep_amount)
VALUES ('9','0','1', '30','1', '009/2017','auto','','2017-12-20', '1', '1','Donald Easter LLC','N/A', '', '0', 'DEF', '2017-12-20','4','70','')<br><br><br>
And here's the contents of the csv file
customer_id,branch_No,reference,date,payment_id,sales_type_name,dimension_id,dimension2_id,item_code,item_description,quantity,unit,price,discountpercentage,freightcost,delfrom,deldate,delto,deladdress,contactphone,email,custref,shipvia,comments,ex_rate
1,1,009/2017,2017/12/20,4,Retail,,,202,Maintenance,2,Each,35,0,,DEF,2017/12/20,Mr A,1 Abe Street Glasgow G32 FHT,984578545,customer@example.in,,,,
1,1,010/2017,2017/12/21,4,Retail,,,202,Maintenance,2,Each,15,0,,DEF,2017/12/21,Mr A,1 Abe Street Glasgow G32 FHT,984578545,customer@example.in,,,,
20 11/09/2023 02:26:57 pm
Re: Import Transactions not working (28 replies, posted in Modules/Add-on's)
I looked at apmuthu file. It did work for FA 2.4.4 after that I tested at 2.4.8 it did not and nothing after that. Not at 2.4.17. I dont know why. Could not figure it out.
21 11/08/2023 11:52:35 pm
Re: Import Transactions not working (28 replies, posted in Modules/Add-on's)
@poncho1234
Yes the Allow Entry on non closed Fiscal Years is found in Access Setup under Banking and GL configuration.
I will take a look at apmuthu file and revert back here.
22 11/08/2023 04:16:22 pm
Re: Import Transactions not working (28 replies, posted in Modules/Add-on's)
@pstevens
I have to admit its not easy to crack Import Transactions module. But once you link all fields correctly then its a piece of cake and you will be proud of yourself. From experience and maybe you have done this already you have to:
Reference should tally i.e If you want to import 004/2022 then your pattern should be {001}/{YYYY} and you make sure 004/2022 does not exist in the system. Also the system will not accept blank reference. It accepts a space (NULL). All fields in the spreadsheet should also be formatted accordingly..i.e Reference is General and Date is Date with the identical date format...etc..Also make sure the Fiscal Year that you are posting into is active and the Banking and GL Configuration has the Allow entry on non closed Fiscal years ticked.
Hope this will help.
23 11/08/2023 12:24:45 pm
Re: 0005724: Bug In Date Editing in Latest FA (7 replies, posted in Report Bugs here)
Create a 2023 fiscal year and try again. No need for it to be the current. Try with active and not active 2023.
Good luck.
24 11/08/2023 06:07:48 am
Re: 0005724: Bug In Date Editing in Latest FA (7 replies, posted in Report Bugs here)
@yubrajkafle99
You need to describe in details what you did to reach this stage. The error clearly mentions a problem in fiscal years for the date entered. So please list your fiscal years opened/closed and your current fiscal year. and to what date you are changing the transaction date.
25 11/07/2023 10:38:12 pm
Re: Transaction References (2 replies, posted in Setup)
Just enter 1001/23 manually in the reference field. The next quote will automatically be 1002/23.